add windows integration tests for states.file

This commit is contained in:
Frode Gundersen 2018-07-24 16:42:07 +00:00
parent 1643bb7fd4
commit a7a914060d
No known key found for this signature in database
GPG key ID: 49E5BDBFA6AFB570
2 changed files with 53 additions and 0 deletions

View file

@ -28,6 +28,7 @@ from tests.support.helpers import (
skip_if_not_root,
with_system_user_and_group,
Webserver,
destructiveTest
)
from tests.support.mixins import SaltReturnAssertsMixin
@ -2471,3 +2472,54 @@ class RemoteFileTest(ModuleCase, SaltReturnAssertsMixin):
skip_verify=True)
log.debug('ret = %s', ret)
self.assertSaltTrueReturn(ret)
@destructiveTest
@skipIf(not salt.utils.is_windows(), 'windows test only')
class WinFileTest(ModuleCase):
'''
Test for the file state on Windows
'''
def setUp(self):
self.test = self.run_state('file.managed', name='c:/testfile', makedirs=True, contents='Only a test')
def tearDown(self):
del self.test
def test_file_managed(self):
'''
Test file.managed on Windows
'''
self.assertTrue(self.run_state('file.exists', name='c:/testfile'))
def test_file_copy(self):
'''
Test file.copy on Windows
'''
ret = self.run_state('file.copy', name='c:/testfile_copy', makedirs=True, source='c:/testfile')
self.assertTrue(ret)
def test_file_comment(self):
'''
Test file.comment on Windows
'''
self.run_state('file.comment', name='c:/testfile', regex='^Only')
file = 'c:/testfile'
with salt.utils.fopen(file, 'r') as fp_:
self.assertTrue(fp_.read().startswith('#Only'))
def test_file_replace(self):
'''
Test file.replace on Windows
'''
self.run_state('file.replace', name='c:/testfile', pattern='test', repl='testing')
file = 'c:/testfile'
with salt.utils.fopen(file, 'r') as fp_:
self.assertIn('testing', fp_.read())
def test_file_absent(self):
'''
Test file.absent on Windows
'''
ret = self.run_state('file.absent', name='c:/testfile')
self.assertTrue(ret)

View file

@ -27,6 +27,7 @@ integration.runners.test_salt
integration.sdb.test_env
integration.states.test_host
integration.states.test_renderers
integration.states.test_file
integration.utils.testprogram
integration.wheel.test_client
integration.wheel.test_key