Move registry api definitions under registry package
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
54ae545ed3
commit
3822e685a0
18 changed files with 2593 additions and 8 deletions
93
docs/api/v2/names_test.go
Normal file
93
docs/api/v2/names_test.go
Normal file
|
@ -0,0 +1,93 @@
|
|||
package v2
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRepositoryNameRegexp(t *testing.T) {
|
||||
for _, testcase := range []struct {
|
||||
input string
|
||||
err error
|
||||
}{
|
||||
{
|
||||
input: "short",
|
||||
},
|
||||
{
|
||||
input: "simple/name",
|
||||
},
|
||||
{
|
||||
input: "library/ubuntu",
|
||||
},
|
||||
{
|
||||
input: "docker/stevvooe/app",
|
||||
},
|
||||
{
|
||||
input: "aa/aa/aa/aa/aa/aa/aa/aa/aa/bb/bb/bb/bb/bb/bb",
|
||||
err: ErrRepositoryNameTooManyComponents,
|
||||
},
|
||||
{
|
||||
input: "aa/aa/bb/bb/bb",
|
||||
},
|
||||
{
|
||||
input: "a/a/a/b/b",
|
||||
err: ErrRepositoryNameComponentShort,
|
||||
},
|
||||
{
|
||||
input: "a/a/a/a/",
|
||||
err: ErrRepositoryNameComponentShort,
|
||||
},
|
||||
{
|
||||
input: "foo.com/bar/baz",
|
||||
},
|
||||
{
|
||||
input: "blog.foo.com/bar/baz",
|
||||
},
|
||||
{
|
||||
input: "asdf",
|
||||
},
|
||||
{
|
||||
input: "asdf$$^/aa",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
},
|
||||
{
|
||||
input: "aa-a/aa",
|
||||
},
|
||||
{
|
||||
input: "aa/aa",
|
||||
},
|
||||
{
|
||||
input: "a-a/a-a",
|
||||
},
|
||||
{
|
||||
input: "a",
|
||||
err: ErrRepositoryNameComponentShort,
|
||||
},
|
||||
{
|
||||
input: "a-/a/a/a",
|
||||
err: ErrRepositoryNameComponentInvalid,
|
||||
},
|
||||
} {
|
||||
|
||||
failf := func(format string, v ...interface{}) {
|
||||
t.Logf(testcase.input+": "+format, v...)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if err := ValidateRespositoryName(testcase.input); err != testcase.err {
|
||||
if testcase.err != nil {
|
||||
if err != nil {
|
||||
failf("unexpected error for invalid repository: got %v, expected %v", err, testcase.err)
|
||||
} else {
|
||||
failf("expected invalid repository: %v", testcase.err)
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
// Wrong error returned.
|
||||
failf("unexpected error validating repository name: %v, expected %v", err, testcase.err)
|
||||
} else {
|
||||
failf("unexpected error validating repository name: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue