mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
commit
2a98891a05
2 changed files with 26 additions and 3 deletions
|
@ -295,12 +295,15 @@ def present(
|
|||
|
||||
# don't do anything because this is a test
|
||||
if __opts__["test"]:
|
||||
ret["result"] = True
|
||||
if __salt__["zpool.exists"](name):
|
||||
ret["changes"][name] = "uptodate"
|
||||
ret["result"] = True
|
||||
ret["comment"] = "storage pool {0} is {1}".format(name, "uptodate")
|
||||
else:
|
||||
ret["result"] = None
|
||||
ret["changes"][name] = "imported" if config["import"] else "created"
|
||||
ret["comment"] = "storage pool {0} was {1}".format(name, ret["changes"][name])
|
||||
ret["comment"] = "storage pool {0} would have been {1}".format(
|
||||
name, ret["changes"][name]
|
||||
)
|
||||
|
||||
# update pool
|
||||
elif __salt__["zpool.exists"](name):
|
||||
|
|
|
@ -487,3 +487,23 @@ class ZpoolTestCase(TestCase, LoaderModuleMockMixin):
|
|||
),
|
||||
ret,
|
||||
)
|
||||
|
||||
# Run state with test=true
|
||||
ret = {
|
||||
"name": "myzpool",
|
||||
"result": True,
|
||||
"comment": "storage pool myzpool is uptodate",
|
||||
"changes": {},
|
||||
}
|
||||
|
||||
with patch.dict(zpool.__salt__, {"zpool.exists": mock_exists}), patch.dict(
|
||||
zpool.__salt__, {"zpool.get": mock_get}
|
||||
), patch.dict(zpool.__utils__, self.utils_patch), patch.dict(
|
||||
zpool.__opts__, {"test": True}
|
||||
):
|
||||
self.assertEqual(
|
||||
zpool.present(
|
||||
"myzpool", config=config, layout=layout, properties=properties,
|
||||
),
|
||||
ret,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue