Skip to content

Commit a7ff1c7

Browse files
committed
osxkeychain: 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 4a8c2d1 commit a7ff1c7

File tree

1 file changed

+49
-25
lines changed

1 file changed

+49
-25
lines changed

osxkeychain/osxkeychain_darwin_test.go

Lines changed: 49 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,25 @@ func TestOSXKeychainHelper(t *testing.T) {
6060
// through variations on the URL
6161
func TestOSXKeychainHelperRetrieveAliases(t *testing.T) {
6262
tests := []struct {
63+
doc string
6364
storeURL string
6465
readURL string
6566
}{
66-
// stored with port, retrieved without
67-
{"https://foobar.docker.io:2376", "https://foobar.docker.io"},
68-
69-
// stored as https, retrieved without scheme
70-
{"https://foobar.docker.io:2376", "foobar.docker.io"},
71-
72-
// stored with path, retrieved without
73-
{"https://foobar.docker.io:1234/one/two", "https://foobar.docker.io:1234"},
67+
{
68+
doc: "stored with port, retrieved without",
69+
storeURL: "https://foobar.docker.io:2376",
70+
readURL: "https://foobar.docker.io",
71+
},
72+
{
73+
doc: "stored as https, retrieved without scheme",
74+
storeURL: "https://foobar.docker.io:2376",
75+
readURL: "foobar.docker.io",
76+
},
77+
{
78+
doc: "stored with path, retrieved without",
79+
storeURL: "https://foobar.docker.io:1234/one/two",
80+
readURL: "https://foobar.docker.io:1234",
81+
},
7482
}
7583

7684
helper := Osxkeychain{}
@@ -102,26 +110,42 @@ func TestOSXKeychainHelperRetrieveAliases(t *testing.T) {
102110
// returned.
103111
func TestOSXKeychainHelperRetrieveStrict(t *testing.T) {
104112
tests := []struct {
113+
doc string
105114
storeURL string
106115
readURL string
107116
}{
108-
// stored as https, retrieved using http
109-
{"https://foobar.docker.io:2376", "http://foobar.docker.io:2376"},
110-
111-
// stored as http, retrieved using https
112-
{"http://foobar.docker.io:2376", "https://foobar.docker.io:2376"},
113-
114-
// same: stored as http, retrieved without a scheme specified (hence, using the default https://)
115-
{"http://foobar.docker.io", "foobar.docker.io:5678"},
116-
117-
// non-matching ports
118-
{"https://foobar.docker.io:1234", "https://foobar.docker.io:5678"},
119-
120-
// non-matching ports TODO is this desired behavior? The other way round does work
121-
// {"https://foobar.docker.io", "https://foobar.docker.io:5678"},
122-
123-
// non-matching paths
124-
{"https://foobar.docker.io:1234/one/two", "https://foobar.docker.io:1234/five/six"},
117+
{
118+
doc: "stored as https, retrieved using http",
119+
storeURL: "https://foobar.docker.io:2376",
120+
readURL: "http://foobar.docker.io:2376",
121+
},
122+
{
123+
doc: "stored as http, retrieved using https",
124+
storeURL: "http://foobar.docker.io:2376",
125+
readURL: "https://foobar.docker.io:2376",
126+
},
127+
{
128+
// stored as http, retrieved without a scheme specified (hence, using the default https://)
129+
doc: "stored as http, retrieved without scheme",
130+
storeURL: "http://foobar.docker.io",
131+
readURL: "foobar.docker.io:5678",
132+
},
133+
{
134+
doc: "non-matching ports",
135+
storeURL: "https://foobar.docker.io:1234",
136+
readURL: "https://foobar.docker.io:5678",
137+
},
138+
// TODO: is this desired behavior? The other way round does work
139+
// {
140+
// doc: "non-matching ports (stored without port)",
141+
// storeURL: "https://foobar.docker.io",
142+
// readURL: "https://foobar.docker.io:5678",
143+
// },
144+
{
145+
doc: "non-matching paths",
146+
storeURL: "https://foobar.docker.io:1234/one/two",
147+
readURL: "https://foobar.docker.io:1234/five/six",
148+
},
125149
}
126150

127151
helper := Osxkeychain{}

0 commit comments

Comments
 (0)