diff --git a/delete_test.go b/delete_test.go index af6371d2..7115997c 100644 --- a/delete_test.go +++ b/delete_test.go @@ -1,6 +1,9 @@ package main -import "testing" +import ( + "strings" + "testing" +) func TestDelete(t *testing.T) { // Make sure we have busybox in list. @@ -8,12 +11,11 @@ func TestDelete(t *testing.T) { if err != nil { t.Fatalf("output: %s, error: %v", string(out), err) } - expected := `Repositories for localhost:5000 -REPO TAGS -busybox latest + expected := `REPO TAGS +busybox glibc, musl, latest alpine latest ` - if out != expected { + if !strings.HasSuffix(out, expected) { t.Fatalf("expected: %s\ngot: %s", expected, out) } @@ -27,11 +29,11 @@ alpine latest if err != nil { t.Fatalf("output: %s, error: %v", string(out), err) } - expected = `Repositories for localhost:5000 -REPO TAGS + expected = `REPO TAGS +busybox glibc, musl alpine latest ` - if out != expected { + if !strings.HasSuffix(out, expected) { t.Fatalf("expected: %s\ngot: %s", expected, out) } } diff --git a/list_test.go b/list_test.go index 50ed4b2b..621bf21f 100644 --- a/list_test.go +++ b/list_test.go @@ -1,17 +1,20 @@ package main -import "testing" +import ( + "strings" + "testing" +) func TestList(t *testing.T) { out, err := run("ls") if err != nil { t.Fatalf("output: %s, error: %v", string(out), err) } - expected := `Repositories for localhost:5000 -REPO TAGS + expected := `REPO TAGS +busybox glibc, musl alpine latest ` - if out != expected { + if !strings.HasSuffix(out, expected) { t.Fatalf("expected: %s\ngot: %s", expected, out) } } diff --git a/main_test.go b/main_test.go index 3fdc4bc2..b2ea9c18 100644 --- a/main_test.go +++ b/main_test.go @@ -90,7 +90,7 @@ func TestMain(m *testing.M) { func run(args ...string) (string, error) { prog := "./testreg" + exeSuffix // always add trust insecure, and the registry - newargs := append([]string{"-k", "-r", "localhost:5000"}, args...) + newargs := append([]string{"-d", "-k", "-r", "localhost:5000"}, args...) cmd := exec.Command(prog, newargs...) out, err := cmd.CombinedOutput() return string(out), err diff --git a/tags_test.go b/tags_test.go new file mode 100644 index 00000000..6042ec07 --- /dev/null +++ b/tags_test.go @@ -0,0 +1,19 @@ +package main + +import ( + "strings" + "testing" +) + +func TestTags(t *testing.T) { + out, err := run("tags", "busybox") + if err != nil { + t.Fatalf("output: %s, error: %v", string(out), err) + } + expected := `glibc +musl +` + if !strings.HasSuffix(out, expected) { + t.Fatalf("expected: %s\ngot: %s", expected, out) + } +} diff --git a/testutils/configs/basicauth.yml b/testutils/configs/basicauth.yml index 4c8f77d4..3026c05b 100644 --- a/testutils/configs/basicauth.yml +++ b/testutils/configs/basicauth.yml @@ -7,6 +7,8 @@ log: storage: filesystem: rootdirectory: /var/lib/registry + delete: + enabled: true http: addr: 0.0.0.0:5000 headers: diff --git a/testutils/configs/noauth.yml b/testutils/configs/noauth.yml index 253cd141..57d3d065 100644 --- a/testutils/configs/noauth.yml +++ b/testutils/configs/noauth.yml @@ -7,6 +7,8 @@ log: storage: filesystem: rootdirectory: /var/lib/registry + delete: + enabled: true http: addr: 0.0.0.0:5000 headers: diff --git a/testutils/testutils.go b/testutils/testutils.go index 48d23569..247d4e5f 100644 --- a/testutils/testutils.go +++ b/testutils/testutils.go @@ -72,12 +72,12 @@ func StartRegistry(dcli *client.Client, config, username, password string) (stri return r.ID, addr, err } - if err := prefillRegistry("alpine:latest", dcli, "localhost"+port, username, password); err != nil { - return r.ID, addr, err - } - - if err := prefillRegistry("busybox:latest", dcli, "localhost"+port, username, password); err != nil { - return r.ID, addr, err + // Prefill the images. + images := []string{"alpine:latest", "busybox:latest", "busybox:musl", "busybox:glibc"} + for _, image := range images { + if err := prefillRegistry(image, dcli, "localhost"+port, username, password); err != nil { + return r.ID, addr, err + } } return r.ID, addr, nil