Merge pull request #55386 from whytewolf/port-54636

Port 54636
This commit is contained in:
Daniel Wozniak 2020-04-14 10:20:44 -07:00 committed by GitHub
commit 2a98891a05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 3 deletions

View file

@ -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):

View file

@ -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,
)