diff options
Diffstat (limited to 'tests/conftest.py')
| -rw-r--r-- | tests/conftest.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index a9452410..b35f190c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py | |||
| @@ -381,10 +381,17 @@ class VdkrRunner: | |||
| 381 | return self.run("load", "-i", str(input_file), timeout=timeout) | 381 | return self.run("load", "-i", str(input_file), timeout=timeout) |
| 382 | 382 | ||
| 383 | def has_image(self, image_name): | 383 | def has_image(self, image_name): |
| 384 | """Check if an image exists.""" | 384 | """Check if an image exists. |
| 385 | |||
| 386 | Uses 'image inspect' for precise matching instead of substring | ||
| 387 | search in 'images' output, which can give false positives | ||
| 388 | (e.g., 'nginx:alpine' matching search for 'alpine'). | ||
| 389 | """ | ||
| 385 | self.ensure_memres() | 390 | self.ensure_memres() |
| 386 | result = self.images() | 391 | # Use image inspect for precise matching - returns 0 if image exists |
| 387 | return image_name.split(":")[0] in result.stdout | 392 | ref = image_name if ":" in image_name else f"{image_name}:latest" |
| 393 | result = self.run("image", "inspect", ref, check=False, capture_output=True) | ||
| 394 | return result.returncode == 0 | ||
| 388 | 395 | ||
| 389 | def ensure_alpine(self, timeout=300): | 396 | def ensure_alpine(self, timeout=300): |
| 390 | """Ensure alpine:latest is available, pulling if necessary.""" | 397 | """Ensure alpine:latest is available, pulling if necessary.""" |
| @@ -585,10 +592,17 @@ class VpdmnRunner: | |||
| 585 | return self.run("load", "-i", str(input_file), timeout=timeout) | 592 | return self.run("load", "-i", str(input_file), timeout=timeout) |
| 586 | 593 | ||
| 587 | def has_image(self, image_name): | 594 | def has_image(self, image_name): |
| 588 | """Check if an image exists.""" | 595 | """Check if an image exists. |
| 596 | |||
| 597 | Uses 'image inspect' for precise matching instead of substring | ||
| 598 | search in 'images' output, which can give false positives | ||
| 599 | (e.g., 'nginx:alpine' matching search for 'alpine'). | ||
| 600 | """ | ||
| 589 | self.ensure_memres() | 601 | self.ensure_memres() |
| 590 | result = self.images() | 602 | # Use image inspect for precise matching - returns 0 if image exists |
| 591 | return image_name.split(":")[0] in result.stdout | 603 | ref = image_name if ":" in image_name else f"{image_name}:latest" |
| 604 | result = self.run("image", "inspect", ref, check=False, capture_output=True) | ||
| 605 | return result.returncode == 0 | ||
| 592 | 606 | ||
| 593 | def ensure_alpine(self, timeout=300): | 607 | def ensure_alpine(self, timeout=300): |
| 594 | """Ensure alpine:latest is available, pulling if necessary.""" | 608 | """Ensure alpine:latest is available, pulling if necessary.""" |
