forked from genuinetools/reg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove_test.go
46 lines (40 loc) · 1.15 KB
/
remove_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
package main
import (
"fmt"
"strings"
"testing"
)
func teardownTest(t *testing.T) {
if err := registryHelper.RefillRegistry("busybox:glibc"); err != nil {
t.Fatalf("adding image after remove failed: +%v", err)
}
}
func TestRemove(t *testing.T) {
defer teardownTest(t)
// Make sure we have busybox in list.
out, err := run("ls", domain)
if err != nil {
t.Fatalf("output: %s, error: %v", out, err)
}
expected := `REPO TAGS
alpine 3.5, latest
busybox glibc, latest, musl`
if !strings.HasSuffix(strings.TrimSpace(out), expected) {
t.Fatalf("expected to contain: %s\ngot: %s", expected, out)
}
// Remove busybox image.
if out, err := run("rm", fmt.Sprintf("%s/busybox:glibc", domain)); err != nil {
t.Fatalf("output: %s, error: %v", out, err)
}
// Make sure we have removed busybox:glibc.
out, err = run("ls", domain)
if err != nil {
t.Fatalf("output: %s, error: %v", out, err)
}
expected = `REPO TAGS
alpine 3.5, latest
busybox latest, musl`
if !strings.HasSuffix(strings.TrimSpace(out), expected) {
t.Fatalf("expected to contain: %s\ngot: %s", expected, out)
}
}