Exemple #1
0
 def test_destroy_error_has_children(self):
     """
     Tests failure return of destroy function on ZFS file system destruction
     """
     res = OrderedDict([
         ("destroyed", False),
         (
             "error",
             "\n".join([
                 "cannot destroy 'myzpool/mydataset': filesystem has children",
                 "use 'recursive=True' to destroy the following datasets:",
                 "myzpool/mydataset@snapshot",
             ]),
         ),
     ])
     ret = {}
     ret["stdout"] = ""
     ret["stderr"] = "\n".join([
         "cannot destroy 'myzpool/mydataset': filesystem has children",
         "use '-r' to destroy the following datasets:",
         "myzpool/mydataset@snapshot",
     ])
     ret["retcode"] = 1
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(zfs.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
             zfs.__utils__, self.utils_patch):
         self.assertEqual(res, zfs.destroy("myzpool/mydataset"))
Exemple #2
0
 def test_destroy_success(self):
     """
     Tests successful return of destroy function on ZFS file system destruction
     """
     res = OrderedDict([("destroyed", True)])
     ret = {}
     ret["stdout"] = ""
     ret["stderr"] = ""
     ret["retcode"] = 0
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(zfs.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
             zfs.__utils__, self.utils_patch):
         self.assertEqual(res, zfs.destroy("myzpool/mydataset"))
Exemple #3
0
def test_destroy_error_not_exists(utils_patch):
    """
    Tests failure return of destroy function on ZFS file system destruction
    """
    res = OrderedDict([
        ("destroyed", False),
        ("error", "cannot open 'myzpool/mydataset': dataset does not exist"),
    ])
    ret = {}
    ret["stdout"] = ""
    ret["stderr"] = "cannot open 'myzpool/mydataset': dataset does not exist"
    ret["retcode"] = 1
    mock_cmd = MagicMock(return_value=ret)
    with patch.dict(zfs.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
            zfs.__utils__, utils_patch):
        assert res == zfs.destroy("myzpool/mydataset")