yep, dryrun option has now a unittest, was hard to work out ...

This commit is contained in:
Daniel Heule 2014-02-11 21:17:19 +01:00
parent 4cca593071
commit 6a5f908269
5 changed files with 24 additions and 0 deletions

View file

@ -2,6 +2,7 @@
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
# 2014 Daniel Heule (hda at sfs.biz)
#
# This file is part of cdist.
#
@ -137,6 +138,22 @@ class ConfigRunTestCase(test.CdistTestCase):
with self.assertRaises(cdist.core.cdist_object.MissingObjectIdError):
self.config.iterate_until_finished()
def test_dryrun(self):
"""Test if the dryrun option is working like expected"""
drylocal = cdist.exec.local.Local(
target_host=self.target_host,
base_path=self.local_dir,
#exec_path can not derivated from sys.argv in case of unittest ...
exec_path=os.path.abspath(os.path.join(my_dir,'../../../scripts/cdist')),
initial_manifest=os.path.join(fixtures, 'manifest/dryrun_manifest'),
add_conf_dirs=[ fixtures ] )
dryrun = cdist.config.Config(drylocal, self.remote, dry_run=True)
dryrun.run()
# if we are here, dryrun works like expected
# 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
# - but maybe only in the emulator - to be discussed.

View file

@ -0,0 +1 @@
__dryrun_test testit

View file

@ -0,0 +1,3 @@
# this type is only for testing the dryrun feature, it does nothing usefull
echo 'echo "This gencode-local script should never be executed >&2"'
echo 'exit 1'

View file

@ -0,0 +1,3 @@
# this type is only for testing the dryrun feature, it does nothing usefull
echo 'echo "this gencode-remote script should never be executed >&2"'
echo 'exit 1'