allow empty list to be a command/entrypoint

Signed-off-by: Sergei Biriukov <svbiriukov@gmail.com>
This commit is contained in:
Sergei Biriukov 2023-04-30 14:56:04 +10:00 committed by Muayyad Alsadi
parent 9011e9faa1
commit d1509468c3
3 changed files with 5 additions and 6 deletions

View File

@ -63,8 +63,6 @@ def is_list(list_object):
def is_list_of_str(list_of_str_object):
if is_list(list_of_str_object):
if len(list_of_str_object) == 0:
return False
for element in list_of_str_object:
if not is_str(element):
return False

View File

@ -2,9 +2,9 @@ from podman_compose import is_list_of_str
def test_is_list_of_str():
assert is_list_of_str([])
assert is_list_of_str(["foo", "bar"])
assert not is_list_of_str(["foo", 1])
assert not is_list_of_str("foo")
assert not is_list_of_str([])
assert not is_list_of_str(1)
assert not is_list_of_str(None)

View File

@ -6,6 +6,10 @@ from podman_compose import rec_merge_one
test_keys = ["command", "entrypoint"]
test_cases = [
({}, {"$$$": []}, {"$$$": []}),
({"$$$": []}, {}, {"$$$": []}),
({"$$$": []}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}),
({"$$$": "sh-2"}, {"$$$": []}, {"$$$": []}),
({}, {"$$$": "sh"}, {"$$$": ["sh"]}),
({"$$$": "sh"}, {}, {"$$$": ["sh"]}),
({"$$$": "sh-1"}, {"$$$": "sh-2"}, {"$$$": ["sh-2"]}),
@ -30,9 +34,6 @@ test_cases_with_exceptions = [
({"$$$": {}}, {}, ValueError),
({}, {"$$$": {}}, ValueError),
({"$$$": {}}, {"$$$": {}}, ValueError),
({"$$$": []}, {}, ValueError),
({}, {"$$$": []}, ValueError),
({"$$$": []}, {"$$$": []}, ValueError),
]