Skip to content

Commit 94a7cc9

Browse files
committed
Added unit test for 'cleanup' function
1 parent be2f38e commit 94a7cc9

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

tests/cli/test_build_images.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77

8-
from murfey.cli.build_images import build_image, push_images, run, tag_image
8+
from murfey.cli.build_images import build_image, cleanup, push_images, run, tag_image
99

1010
images = [f"test_image_{n}" for n in range(3)]
1111

@@ -76,7 +76,7 @@ def test_build_image(mock_subprocess, mock_exists, build_params):
7676

7777

7878
tag_image_params_matrix: tuple[tuple[list[str], list[str], str, bool], ...] = (
79-
# Images | Tags | Source | Destination | User ID | Group ID | Group Name | Dry Run
79+
# Images | Tags | Destination | Dry Run
8080
# Populated flags
8181
(
8282
images,
@@ -118,7 +118,7 @@ def test_tag_image(mock_subprocess, tag_params):
118118

119119

120120
push_image_params_matrix: tuple[tuple[list[str], list[str], str, bool], ...] = (
121-
# Images | Tags | Source | Destination | User ID | Group ID | Group Name | Dry Run
121+
# Images | Tags | Destination | Dry Run
122122
# Populated flags
123123
(
124124
images,
@@ -159,6 +159,27 @@ def test_push_images(
159159
assert result
160160

161161

162+
test_cleanup_params_matrix: tuple[tuple[bool], ...] = ((True,), (False,))
163+
164+
165+
@pytest.mark.parametrize("cleanup_params", test_cleanup_params_matrix)
166+
@patch("murfey.cli.build_images.run_subprocess")
167+
def test_cleanup(
168+
mock_subprocess,
169+
cleanup_params,
170+
):
171+
172+
# Unpack test params
173+
(dry_run,) = cleanup_params
174+
175+
# Mock the subprocess return value
176+
mock_subprocess.return_value = 0
177+
178+
# Run the function
179+
result = cleanup(dry_run)
180+
assert result
181+
182+
162183
test_run_params_matrix: tuple[
163184
tuple[list[str], list[str], str, str, str, str, str, bool], ...
164185
] = (

0 commit comments

Comments
 (0)