mirror of
https://github.com/genuinetools/reg.git
synced 2024-09-28 11:46:20 -04:00
add more tests
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
This commit is contained in:
parent
e55cbf0fa3
commit
72cd07cf34
7 changed files with 47 additions and 19 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
11
list_test.go
11
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
19
tags_test.go
Normal file
19
tags_test.go
Normal file
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -7,6 +7,8 @@ log:
|
|||
storage:
|
||||
filesystem:
|
||||
rootdirectory: /var/lib/registry
|
||||
delete:
|
||||
enabled: true
|
||||
http:
|
||||
addr: 0.0.0.0:5000
|
||||
headers:
|
||||
|
|
|
@ -7,6 +7,8 @@ log:
|
|||
storage:
|
||||
filesystem:
|
||||
rootdirectory: /var/lib/registry
|
||||
delete:
|
||||
enabled: true
|
||||
http:
|
||||
addr: 0.0.0.0:5000
|
||||
headers:
|
||||
|
|
|
@ -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 {
|
||||
// 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
|
||||
}
|
||||
|
||||
if err := prefillRegistry("busybox:latest", dcli, "localhost"+port, username, password); err != nil {
|
||||
return r.ID, addr, err
|
||||
}
|
||||
|
||||
return r.ID, addr, nil
|
||||
|
|
Loading…
Reference in a new issue