summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDale Sedivec <dale@codefu.org>2013-04-07 04:20:10 +0200
committerMichael DeHaan <michael.dehaan@gmail.com>2013-04-17 02:22:51 +0200
commit515fd9e91589e21c7b9d73b797a825e1c5a56ffa (patch)
treeda1d91cca80cc590253a4fba1967ed5ba3862b60 /test
parentMerge pull request #2608 from lwade/ec2zone (diff)
downloadansible-515fd9e91589e21c7b9d73b797a825e1c5a56ffa.tar.xz
ansible-515fd9e91589e21c7b9d73b797a825e1c5a56ffa.zip
copy action plug-in check mode respects force=no
The copy action accepts force=no, which tells it not to replace an existing file even if it differs from the source. The copy action plug-in wasn't respecting this option when operated in check mode, so it would report that changes are necessary in check mode even though copy would make no changes when run normally. Runner._remote_md5 was changed to make the logic for setting rc perhaps a little more clear, and to make sure that rc=0 when the file does not exist.
Diffstat (limited to 'test')
-rw-r--r--test/TestRunner.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/test/TestRunner.py b/test/TestRunner.py
index 21afb4aae4..63f89dc3f3 100644
--- a/test/TestRunner.py
+++ b/test/TestRunner.py
@@ -63,12 +63,13 @@ class TestRunner(unittest.TestCase):
filename = os.path.join(self.stage_dir, filename)
return filename
- def _run(self, module_name, module_args, background=0):
+ def _run(self, module_name, module_args, background=0, check_mode=False):
''' run a module and get the localhost results '''
self.runner.module_name = module_name
args = ' '.join(module_args)
self.runner.module_args = args
self.runner.background = background
+ self.runner.check = check_mode
results = self.runner.run()
# when using nosetests this will only show up on failure
# which is pretty useful
@@ -117,6 +118,12 @@ class TestRunner(unittest.TestCase):
"dest=%s" % output,
])
assert result['changed'] is False
+ with open(output, "a") as output_stream:
+ output_stream.write("output file now differs from input")
+ result = self._run('copy',
+ ["src=%s" % input_, "dest=%s" % output, "force=no"],
+ check_mode=True)
+ assert result['changed'] is False
def test_command(self):
# test command module, change trigger, etc