forked from genuinetools/img
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag_test.go
59 lines (44 loc) · 1.74 KB
/
tag_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
package main
import (
"strings"
"testing"
)
func TestTagImage(t *testing.T) {
runBuild(t, "tagthing", withDockerfile(`
FROM busybox
RUN echo tagtest
`))
run(t, "tag", "tagthing", "jess/tagtest")
out := run(t, "ls")
if !strings.Contains(out, "tagthing:latest") || !strings.Contains(out, "jess/tagtest:latest") {
t.Fatalf("expected ls output to have tagthing:latest and jess/tagtest:latest but got: %s", out)
}
}
func TestTagImageAndPush(t *testing.T) {
runBuild(t, "tagthingandpush", withDockerfile(`
FROM busybox
RUN echo tagtestandpush
`))
run(t, "tag", "tagthingandpush", "jess/tagtestandpush")
out := run(t, "ls")
if !strings.Contains(out, "tagthingandpush:latest") || !strings.Contains(out, "jess/tagtestandpush:latest") {
t.Fatalf("expected ls output to have tagthingandpush:latest and jess/tagtestandpush:latest but got: %s", out)
}
out, err := doRun([]string{"push", "jess/tagtestandpush"}, nil)
if !strings.Contains(err.Error(), "insufficient_scope: authorization failed") {
t.Fatalf("expected push to fail with 'insufficient_scope: authorization failed' got: %s %v", out, err)
}
}
func TestTagPullAndPush(t *testing.T) {
// Test an official image,
run(t, "pull", "busybox")
run(t, "tag", "busybox", "jess/tagpullandpush")
out := run(t, "ls")
if !strings.Contains(out, "busybox:latest") || !strings.Contains(out, "jess/tagpullandpush:latest") {
t.Fatalf("expected ls output to have busybox:latest and jess/tagpullandpush:latest but got: %s", out)
}
out, err := doRun([]string{"push", "jess/tagpullandpush"}, nil)
if !strings.Contains(err.Error(), "insufficient_scope: authorization failed") {
t.Fatalf("expected push to fail with 'insufficient_scope: authorization failed' got: %s %v", out, err)
}
}