mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
add unit test for zfs.clone
This commit is contained in:
parent
a7f742a83d
commit
b7314cd186
@ -314,6 +314,28 @@ class ZfsTestCase(TestCase):
|
||||
with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}):
|
||||
self.assertEqual(zfs.rollback('myzpool/mydataset@yesterday'), res)
|
||||
|
||||
@patch('salt.modules.zfs._check_zfs', MagicMock(return_value='/sbin/zfs'))
|
||||
def test_clone_success(self):
|
||||
'''
|
||||
Tests zfs clone success
|
||||
'''
|
||||
res = {'myzpool/yesterday': 'cloned from myzpool/mydataset@yesterday'}
|
||||
ret = {'pid': 64532, 'retcode': 0, 'stderr': '', 'stdout': ''}
|
||||
mock_cmd = MagicMock(return_value=ret)
|
||||
with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}):
|
||||
self.assertEqual(zfs.clone('myzpool/mydataset@yesterday', 'myzpool/yesterday'), res)
|
||||
|
||||
@patch('salt.modules.zfs._check_zfs', MagicMock(return_value='/sbin/zfs'))
|
||||
def test_clone_failure(self):
|
||||
'''
|
||||
Tests zfs clone failure
|
||||
'''
|
||||
res = {'myzpool/archive/yesterday': "cannot create 'myzpool/archive/yesterday': parent does not exist"}
|
||||
ret = {'pid': 64864, 'retcode': 1, 'stderr': "cannot create 'myzpool/archive/yesterday': parent does not exist", 'stdout': ''}
|
||||
mock_cmd = MagicMock(return_value=ret)
|
||||
with patch.dict(zfs.__salt__, {'cmd.run_all': mock_cmd}):
|
||||
self.assertEqual(zfs.clone('myzpool/mydataset@yesterday', 'myzpool/archive/yesterday'), res)
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
run_tests(ZfsTestCase, needs_daemon=False)
|
||||
|
Loading…
Reference in New Issue
Block a user