mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #48742 from frogunder/45014
add windows integration tests for states.file
This commit is contained in:
commit
8e61f3dce0
2 changed files with 53 additions and 0 deletions
|
@ -30,6 +30,7 @@ from tests.support.helpers import (
|
|||
with_system_user_and_group,
|
||||
with_tempfile,
|
||||
Webserver,
|
||||
destructiveTest
|
||||
)
|
||||
from tests.support.mixins import SaltReturnAssertsMixin
|
||||
|
||||
|
@ -3866,3 +3867,54 @@ class RemoteFileTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
skip_verify=True)
|
||||
log.debug('ret = %s', ret)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
WIN_TEST_FILE = 'c:/testfile'
|
||||
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(not salt.utils.is_windows(), 'windows test only')
|
||||
class WinFileTest(ModuleCase):
|
||||
'''
|
||||
Test for the file state on Windows
|
||||
'''
|
||||
def setUp(self):
|
||||
self.run_state('file.managed', name=WIN_TEST_FILE, makedirs=True, contents='Only a test')
|
||||
|
||||
def tearDown(self):
|
||||
self.run_state('file.absent', name=WIN_TEST_FILE)
|
||||
|
||||
def test_file_managed(self):
|
||||
'''
|
||||
Test file.managed on Windows
|
||||
'''
|
||||
self.assertTrue(self.run_state('file.exists', name=WIN_TEST_FILE))
|
||||
|
||||
def test_file_copy(self):
|
||||
'''
|
||||
Test file.copy on Windows
|
||||
'''
|
||||
ret = self.run_state('file.copy', name='c:/testfile_copy', makedirs=True, source=WIN_TEST_FILE)
|
||||
self.assertTrue(ret)
|
||||
|
||||
def test_file_comment(self):
|
||||
'''
|
||||
Test file.comment on Windows
|
||||
'''
|
||||
self.run_state('file.comment', name=WIN_TEST_FILE, regex='^Only')
|
||||
with salt.utils.fopen(WIN_TEST_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=WIN_TEST_FILE, pattern='test', repl='testing')
|
||||
with salt.utils.fopen(WIN_TEST_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=WIN_TEST_FILE)
|
||||
self.assertTrue(ret)
|
||||
|
|
|
@ -42,6 +42,7 @@ integration.states.test_host
|
|||
integration.states.test_pip_state
|
||||
integration.states.test_pkg
|
||||
integration.states.test_renderers
|
||||
integration.states.test_file
|
||||
integration.states.test_user
|
||||
integration.utils.testprogram
|
||||
integration.wheel.test_client
|
||||
|
|
Loading…
Add table
Reference in a new issue