Allow single character repository names

The main goal of this changeset is to allow repository name components to
consist of a single character. The number of components allowed and the slash
separation requirements have also been clarified.

To go along with this simplification, errant constants and unneeded error types
have been removed.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2015-07-10 12:00:06 -06:00
parent 5ea13fc549
commit a58848a0b7
3 changed files with 37 additions and 36 deletions

View file

@ -1,6 +1,7 @@
package v2
import (
"strconv"
"strings"
"testing"
)
@ -10,6 +11,10 @@ func TestRepositoryNameRegexp(t *testing.T) {
input string
err error
}{
{
input: "",
err: ErrRepositoryNameEmpty,
},
{
input: "short",
},
@ -30,11 +35,26 @@ func TestRepositoryNameRegexp(t *testing.T) {
},
{
input: "a/a/a/b/b",
err: ErrRepositoryNameComponentShort,
},
{
input: "a/a/a/a/",
err: ErrRepositoryNameComponentShort,
err: ErrRepositoryNameComponentInvalid,
},
{
input: "a//a/a",
err: ErrRepositoryNameComponentInvalid,
},
{
input: "a",
},
{
input: "a/aa",
},
{
input: "aa/a",
},
{
input: "a/aa/a",
},
{
input: "foo.com/bar/baz",
@ -58,10 +78,6 @@ func TestRepositoryNameRegexp(t *testing.T) {
{
input: "a-a/a-a",
},
{
input: "a",
err: ErrRepositoryNameComponentShort,
},
{
input: "a-/a/a/a",
err: ErrRepositoryNameComponentInvalid,
@ -110,9 +126,8 @@ func TestRepositoryNameRegexp(t *testing.T) {
err: ErrRepositoryNameComponentInvalid,
},
} {
failf := func(format string, v ...interface{}) {
t.Logf(testcase.input+": "+format, v...)
t.Logf(strconv.Quote(testcase.input)+": "+format, v...)
t.Fail()
}