-
Notifications
You must be signed in to change notification settings - Fork 8
/
container_test.go
54 lines (51 loc) · 1.8 KB
/
container_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
package main
import "testing"
func TestImageRef(t *testing.T) {
data := map[string][]string{
"http://user:[email protected]:5000/org/hanoverd:master-0-g1234567": []string{
"http://user:[email protected]:5000/org/hanoverd", "master-0-g1234567",
},
"http://user:[email protected]:5000/hanoverd:master-0-g1234567": []string{
"http://user:[email protected]:5000/hanoverd", "master-0-g1234567",
},
"http://localhost.localdomain:5000/hanoverd:master-0-g1234567": []string{
"http://localhost.localdomain:5000/hanoverd", "master-0-g1234567",
},
"localhost.localdomain:5000/hanoverd:master-0-g1234567": []string{
"localhost.localdomain:5000/hanoverd", "master-0-g1234567",
},
"localhost.localdomain:5000/hanoverd@0123456789abcdef": []string{
"localhost.localdomain:5000/hanoverd", "0123456789abcdef",
},
"localhost.localdomain:5000/hanoverd": []string{
"localhost.localdomain:5000/hanoverd", "latest",
},
"localhost.localdomain/hanoverd:master-0-g1234567": []string{
"localhost.localdomain/hanoverd", "master-0-g1234567",
},
"localhost.localdomain/hanoverd@0123456789abcdef": []string{
"localhost.localdomain/hanoverd", "0123456789abcdef",
},
"localhost.localdomain/hanoverd": []string{
"localhost.localdomain/hanoverd", "latest",
},
"hanoverd:master-0-g1234567": []string{
"hanoverd", "master-0-g1234567",
},
"hanoverd@0123456789abcdef": []string{
"hanoverd", "0123456789abcdef",
},
"hanoverd": []string{
"hanoverd", "latest",
},
"": []string{
"", "latest",
},
}
for input, expected := range data {
givenName, givenTagDigest := imageRef(input)
if givenName != expected[0] || givenTagDigest != expected[1] {
t.Errorf("Expected: %s %s but got %s %s", expected[0], expected[1], givenName, givenTagDigest)
}
}
}