@@ -8,89 +8,71 @@ import (
88
99func TestValidNamespaces (t * testing.T ) {
1010 for _ , testcase := range []struct {
11- name string
1211 input string
1312 err error
1413 }{
1514 {
16- name : "Default" ,
1715 input : "default" ,
1816 },
1917 {
20- name : "Hyphen" ,
2118 input : "default-default" ,
2219 },
2320 {
24- name : "DoubleHyphen" ,
2521 input : "default--default" ,
2622 },
2723 {
28- name : "containerD" ,
2924 input : "containerd.io" ,
3025 },
3126 {
32- name : "SwarmKit" ,
27+ input : "foo.boo" ,
28+ },
29+ {
3330 input : "swarmkit.docker.io" ,
3431 },
3532 {
36- name : "Punycode" ,
3733 input : "zn--e9.org" , // or something like it!
3834 },
3935 {
40- name : "LeadingPeriod" ,
4136 input : ".foo..foo" ,
4237 err : errNamespaceInvalid ,
4338 },
4439 {
45- name : "Path" ,
4640 input : "foo/foo" ,
4741 err : errNamespaceInvalid ,
4842 },
4943 {
50- name : "ParentDir" ,
5144 input : "foo/.." ,
5245 err : errNamespaceInvalid ,
5346 },
5447 {
55- name : "RepeatedPeriod" ,
5648 input : "foo..foo" ,
5749 err : errNamespaceInvalid ,
5850 },
5951 {
60- name : "OutOfPlaceHyphenEmbedded" ,
6152 input : "foo.-boo" ,
6253 err : errNamespaceInvalid ,
6354 },
6455 {
65- name : "OutOfPlaceHyphen" ,
6656 input : "-foo.boo" ,
6757 err : errNamespaceInvalid ,
6858 },
6959 {
70- name : "OutOfPlaceHyphenEnd" ,
71- input : "foo.boo" ,
60+ input : "foo.boo-" ,
7261 err : errNamespaceInvalid ,
7362 },
7463 {
75- name : "Underscores" ,
7664 input : "foo_foo.boo_underscores" , // boo-urns?
7765 err : errNamespaceInvalid ,
7866 },
7967 } {
80- t .Run (testcase .name , func (t * testing.T ) {
81- if err := Validate (testcase .input ); err != nil {
82- if errors .Cause (err ) != testcase .err {
83- if testcase .err == nil {
84- t .Fatalf ("unexpected error: %v != nil" , err )
85- } else {
86- t .Fatalf ("expected error %v to be %v" , err , testcase .err )
87- }
68+ t .Run (testcase .input , func (t * testing.T ) {
69+ if err := Validate (testcase .input ); errors .Cause (err ) != testcase .err {
70+ t .Log (errors .Cause (err ), testcase .err )
71+ if testcase .err == nil {
72+ t .Fatalf ("unexpected error: %v != nil" , err )
8873 } else {
89- t .Logf ("invalid %q detected as invalid: %v" , testcase .input , err )
90- return
74+ t .Fatalf ("expected error %v to be %v" , err , testcase .err )
9175 }
92-
93- t .Logf ("%q is a valid namespace" , testcase .input )
9476 }
9577 })
9678 }
0 commit comments