Skip to content

Commit ed91395

Browse files
committed
wincred: don't use un-keyed literals in test-tables
Also moving the comments into the test-tables. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 5c5b09e commit ed91395

File tree

1 file changed

+49
-25
lines changed

1 file changed

+49
-25
lines changed

wincred/wincred_windows_test.go

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,25 @@ func TestWinCredHelper(t *testing.T) {
9191
// through variations on the URL
9292
func TestWinCredHelperRetrieveAliases(t *testing.T) {
9393
tests := []struct {
94+
doc string
9495
storeURL string
9596
readURL string
9697
}{
97-
// stored with port, retrieved without
98-
{"https://foobar.docker.io:2376", "https://foobar.docker.io"},
99-
100-
// stored as https, retrieved without scheme
101-
{"https://foobar.docker.io", "foobar.docker.io"},
102-
103-
// stored with path, retrieved without
104-
{"https://foobar.docker.io/one/two", "https://foobar.docker.io"},
98+
{
99+
doc: "stored with port, retrieved without",
100+
storeURL: "https://foobar.docker.io:2376",
101+
readURL: "https://foobar.docker.io",
102+
},
103+
{
104+
doc: "stored as https, retrieved without scheme",
105+
storeURL: "https://foobar.docker.io",
106+
readURL: "foobar.docker.io",
107+
},
108+
{
109+
doc: "stored with path, retrieved without",
110+
storeURL: "https://foobar.docker.io/one/two",
111+
readURL: "https://foobar.docker.io",
112+
},
105113
}
106114

107115
helper := Wincred{}
@@ -133,26 +141,42 @@ func TestWinCredHelperRetrieveAliases(t *testing.T) {
133141
// returned.
134142
func TestWinCredHelperRetrieveStrict(t *testing.T) {
135143
tests := []struct {
144+
doc string
136145
storeURL string
137146
readURL string
138147
}{
139-
// stored as https, retrieved using http
140-
{"https://foobar.docker.io:2376", "http://foobar.docker.io:2376"},
141-
142-
// stored as http, retrieved using https
143-
{"http://foobar.docker.io:2376", "https://foobar.docker.io:2376"},
144-
145-
// same: stored as http, retrieved without a scheme specified (hence, using the default https://)
146-
{"http://foobar.docker.io", "foobar.docker.io:5678"},
147-
148-
// non-matching ports
149-
{"https://foobar.docker.io:1234", "https://foobar.docker.io:5678"},
150-
151-
// non-matching ports TODO is this desired behavior? The other way round does work
152-
// {"https://foobar.docker.io", "https://foobar.docker.io:5678"},
153-
154-
// non-matching paths
155-
{"https://foobar.docker.io:1234/one/two", "https://foobar.docker.io:1234/five/six"},
148+
{
149+
doc: "stored as https, retrieved using http",
150+
storeURL: "https://foobar.docker.io:2376",
151+
readURL: "http://foobar.docker.io:2376",
152+
},
153+
{
154+
doc: "stored as http, retrieved using https",
155+
storeURL: "http://foobar.docker.io:2376",
156+
readURL: "https://foobar.docker.io:2376",
157+
},
158+
{
159+
// stored as http, retrieved without a scheme specified (hence, using the default https://)
160+
doc: "stored as http, retrieved without scheme",
161+
storeURL: "http://foobar.docker.io",
162+
readURL: "foobar.docker.io:5678",
163+
},
164+
{
165+
doc: "non-matching ports",
166+
storeURL: "https://foobar.docker.io:1234",
167+
readURL: "https://foobar.docker.io:5678",
168+
},
169+
// TODO: is this desired behavior? The other way round does work
170+
// {
171+
// doc: "non-matching ports (stored without port)",
172+
// storeURL: "https://foobar.docker.io",
173+
// readURL: "https://foobar.docker.io:5678",
174+
// },
175+
{
176+
doc: "non-matching paths",
177+
storeURL: "https://foobar.docker.io:1234/one/two",
178+
readURL: "https://foobar.docker.io:1234/five/six",
179+
},
156180
}
157181

158182
helper := Wincred{}

0 commit comments

Comments
 (0)