forked from ungleich-public/cdist
Add warning message for faulty dependencies case.
This commit is contained in:
parent
88b436b4c1
commit
d49af95d3c
18 changed files with 138 additions and 3 deletions
|
|
@ -177,6 +177,22 @@ class ConfigRunTestCase(test.CdistTestCase):
|
|||
dryrun.run()
|
||||
# if we are here, dryrun works like expected
|
||||
|
||||
def test_desp_resolver(self):
|
||||
"""Test to show dependency resolver warning message."""
|
||||
local = cdist.exec.local.Local(
|
||||
target_host=self.target_host,
|
||||
base_root_path=self.host_base_path,
|
||||
host_dir_name=self.hostdir,
|
||||
exec_path=os.path.abspath(os.path.join(
|
||||
my_dir, '../../../scripts/cdist')),
|
||||
initial_manifest=os.path.join(
|
||||
fixtures, 'manifest/init-deps-resolver'),
|
||||
add_conf_dirs=[fixtures])
|
||||
|
||||
# dry_run is ok for dependency testing
|
||||
config = cdist.config.Config(local, self.remote, dry_run=True)
|
||||
config.run()
|
||||
|
||||
|
||||
# Currently the resolving code will simply detect that this object does
|
||||
# not exist. It should probably check if the type is a singleton as well
|
||||
|
|
|
|||
8
cdist/test/config/fixtures/manifest/init-deps-resolver
Normal file
8
cdist/test/config/fixtures/manifest/init-deps-resolver
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
__a a
|
||||
require="__e/e" __b b
|
||||
require="__f/f" __c c
|
||||
__e e
|
||||
__f f
|
||||
require="__c/c" __d d
|
||||
__g g
|
||||
__h h
|
||||
0
cdist/test/config/fixtures/type/__a/.keep
Normal file
0
cdist/test/config/fixtures/type/__a/.keep
Normal file
0
cdist/test/config/fixtures/type/__b/.keep
Normal file
0
cdist/test/config/fixtures/type/__b/.keep
Normal file
0
cdist/test/config/fixtures/type/__c/.keep
Normal file
0
cdist/test/config/fixtures/type/__c/.keep
Normal file
0
cdist/test/config/fixtures/type/__d/.keep
Normal file
0
cdist/test/config/fixtures/type/__d/.keep
Normal file
0
cdist/test/config/fixtures/type/__e/.keep
Normal file
0
cdist/test/config/fixtures/type/__e/.keep
Normal file
0
cdist/test/config/fixtures/type/__f/.keep
Normal file
0
cdist/test/config/fixtures/type/__f/.keep
Normal file
0
cdist/test/config/fixtures/type/__g/.keep
Normal file
0
cdist/test/config/fixtures/type/__g/.keep
Normal file
1
cdist/test/config/fixtures/type/__g/manifest
Normal file
1
cdist/test/config/fixtures/type/__g/manifest
Normal file
|
|
@ -0,0 +1 @@
|
|||
require="__c/c __d/d" __a a
|
||||
0
cdist/test/config/fixtures/type/__h/.keep
Normal file
0
cdist/test/config/fixtures/type/__h/.keep
Normal file
3
cdist/test/config/fixtures/type/__h/manifest
Normal file
3
cdist/test/config/fixtures/type/__h/manifest
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# require="__b/b" __a a
|
||||
require="__j/j" __i i
|
||||
__j j
|
||||
0
cdist/test/config/fixtures/type/__i/.keep
Normal file
0
cdist/test/config/fixtures/type/__i/.keep
Normal file
0
cdist/test/config/fixtures/type/__j/.keep
Normal file
0
cdist/test/config/fixtures/type/__j/.keep
Normal file
|
|
@ -499,6 +499,60 @@ class StdinTestCase(test.CdistTestCase):
|
|||
self.assertEqual(random_string, stdin_saved_by_emulator)
|
||||
|
||||
|
||||
class EmulatorAlreadyExistingRequirementsWarnTestCase(test.CdistTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.temp_dir = self.mkdtemp()
|
||||
handle, self.script = self.mkstemp(dir=self.temp_dir)
|
||||
os.close(handle)
|
||||
base_path = self.temp_dir
|
||||
hostdir = cdist.str_hash(self.target_host[0])
|
||||
host_base_path = os.path.join(base_path, hostdir)
|
||||
|
||||
self.local = local.Local(
|
||||
target_host=self.target_host,
|
||||
base_root_path=host_base_path,
|
||||
host_dir_name=hostdir,
|
||||
exec_path=test.cdist_exec_path,
|
||||
add_conf_dirs=[conf_dir])
|
||||
self.local.create_files_dirs()
|
||||
|
||||
self.manifest = core.Manifest(self.target_host, self.local)
|
||||
self.env = self.manifest.env_initial_manifest(self.script)
|
||||
self.env['__cdist_object_marker'] = self.local.object_marker_name
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.temp_dir)
|
||||
|
||||
def test_object_existing_requirements_req_none(self):
|
||||
"""Test to show dependency resolver warning message."""
|
||||
argv = ['__directory', 'spam']
|
||||
emu = emulator.Emulator(argv, env=self.env)
|
||||
emu.run()
|
||||
argv = ['__file', 'eggs']
|
||||
self.env['require'] = '__directory/spam'
|
||||
emu = emulator.Emulator(argv, env=self.env)
|
||||
emu.run()
|
||||
argv = ['__file', 'eggs']
|
||||
if 'require' in self.env:
|
||||
del self.env['require']
|
||||
emu = emulator.Emulator(argv, env=self.env)
|
||||
|
||||
def test_object_existing_requirements_none_req(self):
|
||||
"""Test to show dependency resolver warning message."""
|
||||
argv = ['__directory', 'spam']
|
||||
emu = emulator.Emulator(argv, env=self.env)
|
||||
emu.run()
|
||||
argv = ['__file', 'eggs']
|
||||
if 'require' in self.env:
|
||||
del self.env['require']
|
||||
emu = emulator.Emulator(argv, env=self.env)
|
||||
emu.run()
|
||||
argv = ['__file', 'eggs']
|
||||
self.env['require'] = '__directory/spam'
|
||||
emu = emulator.Emulator(argv, env=self.env)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import unittest
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue