mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #47064 from dwoz/roots_tests_fix
Fix fileserver roots tests
This commit is contained in:
commit
7fddad6cd9
1 changed files with 13 additions and 4 deletions
|
@ -57,6 +57,14 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
|||
cls.test_symlink_list_file_roots = {'base': [root_dir]}
|
||||
else:
|
||||
cls.test_symlink_list_file_roots = None
|
||||
cls.tmp_dir = tempfile.mkdtemp(dir=TMP)
|
||||
full_path_to_file = os.path.join(FILES, 'file', 'base', 'testfile')
|
||||
with salt.utils.fopen(full_path_to_file, 'rb') as s_fp:
|
||||
with salt.utils.fopen(os.path.join(cls.tmp_dir, 'testfile'), 'wb') as d_fp:
|
||||
for line in s_fp:
|
||||
d_fp.write(
|
||||
line.rstrip(b'\n').rstrip(b'\r') + os.linesep.encode('utf-8')
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
|
@ -68,6 +76,7 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
|||
salt.utils.rm_rf(cls.test_symlink_list_file_roots['base'][0])
|
||||
except OSError:
|
||||
pass
|
||||
salt.utils.rm_rf(cls.tmp_dir)
|
||||
|
||||
def tearDown(self):
|
||||
del self.opts
|
||||
|
@ -86,10 +95,10 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
|||
def test_serve_file(self):
|
||||
with patch.dict(roots.__opts__, {'file_buffer_size': 262144}):
|
||||
load = {'saltenv': 'base',
|
||||
'path': os.path.join(FILES, 'file', 'base', 'testfile'),
|
||||
'path': os.path.join(self.tmp_dir, 'testfile'),
|
||||
'loc': 0
|
||||
}
|
||||
fnd = {'path': os.path.join(FILES, 'file', 'base', 'testfile'),
|
||||
fnd = {'path': os.path.join(self.tmp_dir, 'testfile'),
|
||||
'rel': 'testfile'}
|
||||
ret = roots.serve_file(load, fnd)
|
||||
|
||||
|
@ -134,10 +143,10 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
|||
def test_file_hash(self):
|
||||
load = {
|
||||
'saltenv': 'base',
|
||||
'path': os.path.join(FILES, 'file', 'base', 'testfile'),
|
||||
'path': os.path.join(self.tmp_dir, 'testfile'),
|
||||
}
|
||||
fnd = {
|
||||
'path': os.path.join(FILES, 'file', 'base', 'testfile'),
|
||||
'path': os.path.join(self.tmp_dir, 'testfile'),
|
||||
'rel': 'testfile'
|
||||
}
|
||||
ret = roots.file_hash(load, fnd)
|
||||
|
|
Loading…
Add table
Reference in a new issue