-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhich_registry_test.go
72 lines (67 loc) · 1.44 KB
/
which_registry_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package which_registry
import (
"testing"
)
func TestWhich(t *testing.T) {
type test struct {
image string
registry Registry
}
tests := []test{
{
image: "nginx:alpine",
registry: DOCKER_HUB,
},
{
image: "public.ecr.aws/nginx/nginx:1.21",
registry: ECR_PUBLIC,
},
{
image: "111111111111.dkr.ecr.us-east-1.amazonaws.com/nginx:1.21",
registry: ECR_PRIVATE,
},
{
image: "us-east1-docker.pkg.dev/my-project/my-repo/test-image",
registry: GOOGLE_ARTIFACT_REGISTRY,
},
{
image: "us-docker.pkg.dev/my-project/my-repo/test-image",
registry: GOOGLE_ARTIFACT_REGISTRY,
},
{
image: "gcr.io/example.com/my-project/image-name",
registry: GOOGLE_CONTAINER_REGISTRY,
},
{
image: "us.gcr.io/builds/product1/dev/product1-app:beta-2.0",
registry: GOOGLE_CONTAINER_REGISTRY,
},
{
image: "docker.elastic.co/elasticsearch/elasticsearch",
registry: UNKNOWN,
},
{
image: "quay.io/bitnami/nginx",
registry: QUAY_IO,
},
{
image: "ghcr.io/parca-dev/parca:v0.11.1",
registry: GITHUB_CONTAINER_REGISTRY,
},
}
for _, test := range tests {
r, err := Which(test.image)
if err != nil {
t.Fatalf("failed test: %v\n", err)
}
if r != test.registry {
t.Fatalf("failed test: %v %v\n", test.image, r)
}
}
}
func TestParseRepo(t *testing.T) {
r := "docker.io/library/nginx"
if parseRepo(r) != "docker.io" {
t.Fatalf("failed test: %v\n", r)
}
}