Skip to content

Commit c04652e

Browse files
committed
Replace mocked find_image tests with real ones
1 parent 9753570 commit c04652e

File tree

5 files changed

+25
-31
lines changed

5 files changed

+25
-31
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
- unit
6666
- venv
6767
- contentproviders
68-
- registry
68+
- norun
6969
# Playwright test
7070
- ui
7171
include:
File renamed without changes.

tests/norun/test_find.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import secrets
2+
from pathlib import Path
3+
4+
from repo2docker.__main__ import make_r2d
5+
6+
HERE = Path(__file__).parent
7+
8+
9+
def test_find_image():
10+
image_name = f"{secrets.token_hex(8)}:latest"
11+
r2d = make_r2d(["--image", image_name, "--no-run", str(HERE)])
12+
13+
r2d.start()
14+
15+
assert r2d.find_image()
16+
17+
18+
def test_dont_find_image():
19+
image_name = f"{secrets.token_hex(8)}:latest"
20+
r2d = make_r2d(["--image", image_name, "--no-run", str(HERE)])
21+
22+
# Just don't actually start the build, so image won't be found
23+
assert not r2d.find_image()

tests/registry/test_registry.py tests/norun/test_registry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@ def test_registry(registry, dind):
116116
r2d.start()
117117

118118
proc = subprocess.run(["docker", "manifest", "inspect", "--insecure", image_name])
119-
assert proc.returncode == 0
119+
assert proc.returncode == 0

tests/unit/test_app.py

-29
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,6 @@
1010
from repo2docker.app import Repo2Docker
1111
from repo2docker.utils import chdir
1212

13-
14-
def test_find_image():
15-
images = [{"RepoTags": ["some-org/some-repo:latest"]}]
16-
17-
with patch("repo2docker.docker.docker.APIClient") as FakeDockerClient:
18-
instance = FakeDockerClient.return_value
19-
instance.images.return_value = images
20-
21-
r2d = Repo2Docker()
22-
r2d.output_image_spec = "some-org/some-repo"
23-
assert r2d.find_image()
24-
25-
instance.images.assert_called_with()
26-
27-
28-
def test_dont_find_image():
29-
images = [{"RepoTags": ["some-org/some-image-name:latest"]}]
30-
31-
with patch("repo2docker.docker.docker.APIClient") as FakeDockerClient:
32-
instance = FakeDockerClient.return_value
33-
instance.images.return_value = images
34-
35-
r2d = Repo2Docker()
36-
r2d.output_image_spec = "some-org/some-other-image-name"
37-
assert not r2d.find_image()
38-
39-
instance.images.assert_called_with()
40-
41-
4213
def test_image_name_remains_unchanged():
4314
# if we specify an image name, it should remain unmodified
4415
with TemporaryDirectory() as src:

0 commit comments

Comments
 (0)