test: make test cases unique and test de-duplication
CI / Test Setup Trivy amd64 (pull_request) Successful in 9s
CI / Test Setup DB (pull_request) Successful in 15s
CI / Test Get Images From Files (pull_request) Successful in 20s
CI / Test Setup Trivy arm64 (pull_request) Successful in 23s

This commit is contained in:
2026-02-05 14:34:21 +01:00
parent 923962f961
commit 61da085e0f
3 changed files with 30 additions and 26 deletions
+12 -9
View File
@@ -49,13 +49,16 @@ jobs:
run: |
images="${{ steps.giff.outputs.images }}"
echo "Extracted: $images"
# Registry with tag
echo "$images" | grep -q 'example.com/library/nginx:latest'
echo "$images" | grep -q 'example.com/library/redis:7-alpine'
echo "$images" | grep -q 'example.com/library/app:1.25-alpine'
# Registry path with tag
# Dockerfile-only: registry with tag, registry with digest
echo "$images" | grep -q 'example.com/library/nginx:v1'
echo "$images" | grep -q 'example.com/library/base@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
# K8s-only: registry with tag, registry with digest
echo "$images" | grep -q 'example.com/library/app:v2'
echo "$images" | grep -q 'example.com/myproject/helper@sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
# Shared ref (in both Dockerfile and K8s) — must appear exactly once
echo "$images" | grep -q 'example.com/distroless/static:nonroot'
# Registry with digest
echo "$images" | grep -q 'example.com/distroless/static@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd'
echo "$images" | grep -q 'example.com/library/alpine@sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
echo "$images" | grep -q 'example.com/myproject/myimg@sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd'
count=$(echo "$images" | tr ',' '\n' | grep -c 'example.com/distroless/static:nonroot' || true)
[ "$count" -eq 1 ] || { echo "expected shared ref once, got: $count"; exit 1; }
# Total unique refs: 5
total=$(echo "$images" | tr ',' '\n' | grep -c . || true)
[ "$total" -eq 5 ] || { echo "expected 5 unique refs, got: $total"; exit 1; }