mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
add tests for file.serialize check_cmd usage
This commit is contained in:
parent
a66c4fc174
commit
2cff8b35fa
1 changed files with 34 additions and 0 deletions
|
@ -147,3 +147,37 @@ def test_serializer_plist_file_open(file, tmp_path):
|
|||
serialized_data = salt.serializers.plist.deserialize(name.read_bytes())
|
||||
# make sure our serialized data matches what we expect
|
||||
assert serialized_data["foo"] == merged["foo"]
|
||||
|
||||
|
||||
def test_serialize_check_cmd(file, tmp_path):
|
||||
# pass
|
||||
path_test = tmp_path / "test_serialize_check_cmd"
|
||||
dataset_one = {
|
||||
"name": "naive",
|
||||
"description": "A basic test",
|
||||
"a_list": ["first_element", "second_element"],
|
||||
}
|
||||
ret = file.serialize(
|
||||
name=str(path_test),
|
||||
dataset=dataset_one,
|
||||
serializer="json",
|
||||
check_cmd="grep 'first_element'",
|
||||
)
|
||||
assert ret.result is True
|
||||
|
||||
# fail
|
||||
dataset_two = {
|
||||
"name": "naive",
|
||||
"description": "A basic test",
|
||||
"a_list": ["first_element", "second_element"],
|
||||
"finally": "the last item",
|
||||
}
|
||||
ret = file.serialize(
|
||||
name=str(path_test),
|
||||
dataset=dataset_two,
|
||||
serializer="json",
|
||||
check_cmd="grep 'fifth_element'",
|
||||
)
|
||||
assert ret.result is False
|
||||
|
||||
assert json.loads(path_test.read_text()) == dataset_one
|
||||
|
|
Loading…
Add table
Reference in a new issue