Write an integration test demonstrating the issue

This commit is contained in:
rallytime 2016-12-01 16:52:03 -07:00
parent 6942d5d95b
commit f2c045520d

View File

@ -1233,6 +1233,11 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
# write a line to file
with salt.utils.fopen(name, 'w+') as fp_:
fp_.write('comment_me')
# Look for changes with test=True: return should be "None" at the first run
ret = self.run_state('file.comment', test=True, name=name, regex='^comment')
self.assertSaltNoneReturn(ret)
# comment once
ret = self.run_state('file.comment', name=name, regex='^comment')
# result is positive
@ -1248,6 +1253,11 @@ class FileTest(integration.ModuleCase, integration.SaltReturnAssertsMixIn):
# line is still commented
with salt.utils.fopen(name, 'r') as fp_:
self.assertTrue(fp_.read().startswith('#comment'))
# Test previously commented file returns "True" now and not "None" with test=True
ret = self.run_state('file.comment', test=True, name=name, regex='^comment')
self.assertSaltTrueReturn(ret)
finally:
os.remove(name)