|
5 | 5 |
|
6 | 6 | import pytest |
7 | 7 |
|
8 | | -from murfey.cli.build_images import build_image, run, tag_image |
| 8 | +from murfey.cli.build_images import build_image, push_images, run, tag_image |
9 | 9 |
|
10 | 10 | images = [f"test_image_{n}" for n in range(3)] |
11 | 11 |
|
@@ -147,9 +147,50 @@ def test_tag_image(mock_subprocess, tag_params): |
147 | 147 | ) |
148 | 148 |
|
149 | 149 |
|
| 150 | +push_image_params_matrix: tuple[tuple[list[str], list[str], str, bool], ...] = ( |
| 151 | + # Images | Tags | Source | Destination | User ID | Group ID | Group Name | Dry Run |
| 152 | + # Populated flags |
| 153 | + ( |
| 154 | + images, |
| 155 | + ["latest", "dev", "1.1.1"], |
| 156 | + "docker.io", |
| 157 | + False, |
| 158 | + ), |
| 159 | + ( |
| 160 | + images, |
| 161 | + ["latest", "dev", "1.1.1"], |
| 162 | + "docker.io", |
| 163 | + True, |
| 164 | + ), |
| 165 | +) |
| 166 | + |
| 167 | + |
| 168 | +@pytest.mark.parametrize("push_params", push_image_params_matrix) |
| 169 | +@patch("murfey.cli.build_images.run_subprocess") |
| 170 | +def test_push_images( |
| 171 | + mock_subprocess, |
| 172 | + push_params, |
| 173 | +): |
| 174 | + |
| 175 | + # Unpack test parameters |
| 176 | + images, tags, dst, dry_run = push_params |
| 177 | + |
| 178 | + # Construct all images to be pushed |
| 179 | + images_to_push = [f"{dst}/{image}:{tag}" for image in images for tag in tags] |
| 180 | + |
| 181 | + # Mock the subprocess return value |
| 182 | + mock_subprocess.return_value = True |
| 183 | + |
| 184 | + # Run the function |
| 185 | + result = push_images( |
| 186 | + images=images_to_push, |
| 187 | + dry_run=dry_run, |
| 188 | + ) |
| 189 | + assert result |
| 190 | + |
| 191 | + |
150 | 192 | @pytest.mark.parametrize("run_params", test_run_params_matrix) |
151 | 193 | @patch("murfey.cli.build_images.Path.exists") |
152 | | -@patch("murfey.cli.build_images.run_subprocess") |
153 | 194 | @patch("murfey.cli.build_images.cleanup") |
154 | 195 | @patch("murfey.cli.build_images.push_images") |
155 | 196 | @patch("murfey.cli.build_images.tag_image") |
|
0 commit comments