Add test case for --output-file-append

This commit is contained in:
Pedro Algarvio 2014-08-20 02:41:35 +01:00
parent 1e2460e504
commit bf406bf459

View File

@ -22,6 +22,7 @@ ensure_in_syspath('../../')
# Import salt libs
import integration
import salt.utils
class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
@ -276,6 +277,39 @@ class CallTest(integration.ShellCase, integration.ShellCaseCommonTestsMixIn):
if os.path.isdir(config_dir):
shutil.rmtree(config_dir)
def test_issue_15074_output_file_append(self):
output_file_append = os.path.join(integration.TMP, 'issue-15074')
try:
# Let's create an initial output file with some data
ret = self.run_script(
'salt-call',
'-c {0} --output-file={1} -g'.format(
self.get_config_dir(),
output_file_append
),
catch_stderr=True,
with_retcode=True
)
print ret
with salt.utils.fopen(output_file_append) as ofa:
output = ofa.read()
self.run_script(
'salt-call',
'-c {0} --output-file={1} --output-file-append -g'.format(
self.get_config_dir(),
output_file_append
),
catch_stderr=True,
with_retcode=True
)
with salt.utils.fopen(output_file_append) as ofa:
self.assertEqual(ofa.read(), output + output)
finally:
if os.path.exists(output_file_append):
os.unlink(output_file_append)
if __name__ == '__main__':
from integration import run_tests