Skip to content

Commit 810dcd4

Browse files
committed
use "tc" for test-cases
Mostly for my own sanity; just about every repository we have started to converge to using "tc" as variable name for this, so updating this repository as well to help reduce cognitive load. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent f09e79d commit 810dcd4

File tree

3 files changed

+74
-74
lines changed

3 files changed

+74
-74
lines changed

osxkeychain/osxkeychain_darwin_test.go

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,26 +75,26 @@ func TestOSXKeychainHelperRetrieveAliases(t *testing.T) {
7575

7676
helper := Osxkeychain{}
7777
defer func() {
78-
for _, te := range tests {
79-
helper.Delete(te.storeURL)
78+
for _, tc := range tests {
79+
helper.Delete(tc.storeURL)
8080
}
8181
}()
8282

8383
// Clean store before testing.
84-
for _, te := range tests {
85-
helper.Delete(te.storeURL)
84+
for _, tc := range tests {
85+
helper.Delete(tc.storeURL)
8686
}
8787

88-
for _, te := range tests {
89-
c := &credentials.Credentials{ServerURL: te.storeURL, Username: "hello", Secret: "world"}
88+
for _, tc := range tests {
89+
c := &credentials.Credentials{ServerURL: tc.storeURL, Username: "hello", Secret: "world"}
9090
if err := helper.Add(c); err != nil {
91-
t.Errorf("Error: failed to store secret for URL %q: %s", te.storeURL, err)
91+
t.Errorf("Error: failed to store secret for URL %q: %s", tc.storeURL, err)
9292
continue
9393
}
94-
if _, _, err := helper.Get(te.readURL); err != nil {
95-
t.Errorf("Error: failed to read secret for URL %q using %q", te.storeURL, te.readURL)
94+
if _, _, err := helper.Get(tc.readURL); err != nil {
95+
t.Errorf("Error: failed to read secret for URL %q using %q", tc.storeURL, tc.readURL)
9696
}
97-
helper.Delete(te.storeURL)
97+
helper.Delete(tc.storeURL)
9898
}
9999
}
100100

@@ -118,34 +118,34 @@ func TestOSXKeychainHelperRetrieveStrict(t *testing.T) {
118118
{"https://foobar.docker.io:1234", "https://foobar.docker.io:5678"},
119119

120120
// non-matching ports TODO is this desired behavior? The other way round does work
121-
//{"https://foobar.docker.io", "https://foobar.docker.io:5678"},
121+
// {"https://foobar.docker.io", "https://foobar.docker.io:5678"},
122122

123123
// non-matching paths
124124
{"https://foobar.docker.io:1234/one/two", "https://foobar.docker.io:1234/five/six"},
125125
}
126126

127127
helper := Osxkeychain{}
128128
defer func() {
129-
for _, te := range tests {
130-
helper.Delete(te.storeURL)
129+
for _, tc := range tests {
130+
helper.Delete(tc.storeURL)
131131
}
132132
}()
133133

134134
// Clean store before testing.
135-
for _, te := range tests {
136-
helper.Delete(te.storeURL)
135+
for _, tc := range tests {
136+
helper.Delete(tc.storeURL)
137137
}
138138

139-
for _, te := range tests {
140-
c := &credentials.Credentials{ServerURL: te.storeURL, Username: "hello", Secret: "world"}
139+
for _, tc := range tests {
140+
c := &credentials.Credentials{ServerURL: tc.storeURL, Username: "hello", Secret: "world"}
141141
if err := helper.Add(c); err != nil {
142-
t.Errorf("Error: failed to store secret for URL %q: %s", te.storeURL, err)
142+
t.Errorf("Error: failed to store secret for URL %q: %s", tc.storeURL, err)
143143
continue
144144
}
145-
if _, _, err := helper.Get(te.readURL); err == nil {
146-
t.Errorf("Error: managed to read secret for URL %q using %q, but should not be able to", te.storeURL, te.readURL)
145+
if _, _, err := helper.Get(tc.readURL); err == nil {
146+
t.Errorf("Error: managed to read secret for URL %q using %q, but should not be able to", tc.storeURL, tc.readURL)
147147
}
148-
helper.Delete(te.storeURL)
148+
helper.Delete(tc.storeURL)
149149
}
150150
}
151151

@@ -167,39 +167,39 @@ func TestOSXKeychainHelperStoreRetrieve(t *testing.T) {
167167

168168
helper := Osxkeychain{}
169169
defer func() {
170-
for _, te := range tests {
171-
helper.Delete(te.url)
170+
for _, tc := range tests {
171+
helper.Delete(tc.url)
172172
}
173173
}()
174174

175175
// Clean store before testing.
176-
for _, te := range tests {
177-
helper.Delete(te.url)
176+
for _, tc := range tests {
177+
helper.Delete(tc.url)
178178
}
179179

180180
// Note that we don't delete between individual tests here, to verify that
181181
// subsequent stores/overwrites don't affect storing / retrieving secrets.
182-
for i, te := range tests {
182+
for i, tc := range tests {
183183
c := &credentials.Credentials{
184-
ServerURL: te.url,
184+
ServerURL: tc.url,
185185
Username: fmt.Sprintf("user-%d", i),
186186
Secret: fmt.Sprintf("secret-%d", i),
187187
}
188188

189189
if err := helper.Add(c); err != nil {
190-
t.Errorf("Error: failed to store secret for URL: %s: %s", te.url, err)
190+
t.Errorf("Error: failed to store secret for URL: %s: %s", tc.url, err)
191191
continue
192192
}
193-
user, secret, err := helper.Get(te.url)
193+
user, secret, err := helper.Get(tc.url)
194194
if err != nil {
195-
t.Errorf("Error: failed to read secret for URL %q: %s", te.url, err)
195+
t.Errorf("Error: failed to read secret for URL %q: %s", tc.url, err)
196196
continue
197197
}
198198
if user != c.Username {
199-
t.Errorf("Error: expected username %s, got username %s for URL: %s", c.Username, user, te.url)
199+
t.Errorf("Error: expected username %s, got username %s for URL: %s", c.Username, user, tc.url)
200200
}
201201
if secret != c.Secret {
202-
t.Errorf("Error: expected secret %s, got secret %s for URL: %s", c.Secret, secret, te.url)
202+
t.Errorf("Error: expected secret %s, got secret %s for URL: %s", c.Secret, secret, tc.url)
203203
}
204204
}
205205
}

registryurl/parse_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ func TestHelperParseURL(t *testing.T) {
2424
{url: "ftp://foobar.docker.io:2376", err: errors.New("unsupported scheme: ftp")},
2525
}
2626

27-
for _, te := range tests {
28-
u, err := Parse(te.url)
27+
for _, tc := range tests {
28+
u, err := Parse(tc.url)
2929

30-
if te.err == nil && err != nil {
31-
t.Errorf("Error: failed to parse URL %q: %s", te.url, err)
30+
if tc.err == nil && err != nil {
31+
t.Errorf("Error: failed to parse URL %q: %s", tc.url, err)
3232
continue
3333
}
34-
if te.err != nil && err == nil {
35-
t.Errorf("Error: expected error %q, got none when parsing URL %q", te.err, te.url)
34+
if tc.err != nil && err == nil {
35+
t.Errorf("Error: expected error %q, got none when parsing URL %q", tc.err, tc.url)
3636
continue
3737
}
38-
if te.err != nil && err.Error() != te.err.Error() {
39-
t.Errorf("Error: expected error %q, got %q when parsing URL %q", te.err, err, te.url)
38+
if tc.err != nil && err.Error() != tc.err.Error() {
39+
t.Errorf("Error: expected error %q, got %q when parsing URL %q", tc.err, err, tc.url)
4040
continue
4141
}
42-
if u != nil && u.String() != te.expectedURL {
43-
t.Errorf("Error: expected URL: %q, but got %q for URL: %q", te.expectedURL, u.String(), te.url)
42+
if u != nil && u.String() != tc.expectedURL {
43+
t.Errorf("Error: expected URL: %q, but got %q for URL: %q", tc.expectedURL, u.String(), tc.url)
4444
}
4545
}
4646
}

wincred/wincred_windows_test.go

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,26 @@ func TestWinCredHelperRetrieveAliases(t *testing.T) {
106106

107107
helper := Wincred{}
108108
defer func() {
109-
for _, te := range tests {
110-
helper.Delete(te.storeURL)
109+
for _, tc := range tests {
110+
helper.Delete(tc.storeURL)
111111
}
112112
}()
113113

114114
// Clean store before testing.
115-
for _, te := range tests {
116-
helper.Delete(te.storeURL)
115+
for _, tc := range tests {
116+
helper.Delete(tc.storeURL)
117117
}
118118

119-
for _, te := range tests {
120-
c := &credentials.Credentials{ServerURL: te.storeURL, Username: "hello", Secret: "world"}
119+
for _, tc := range tests {
120+
c := &credentials.Credentials{ServerURL: tc.storeURL, Username: "hello", Secret: "world"}
121121
if err := helper.Add(c); err != nil {
122-
t.Errorf("Error: failed to store secret for URL %q: %s", te.storeURL, err)
122+
t.Errorf("Error: failed to store secret for URL %q: %s", tc.storeURL, err)
123123
continue
124124
}
125-
if _, _, err := helper.Get(te.readURL); err != nil {
126-
t.Errorf("Error: failed to read secret for URL %q using %q", te.storeURL, te.readURL)
125+
if _, _, err := helper.Get(tc.readURL); err != nil {
126+
t.Errorf("Error: failed to read secret for URL %q using %q", tc.storeURL, tc.readURL)
127127
}
128-
helper.Delete(te.storeURL)
128+
helper.Delete(tc.storeURL)
129129
}
130130
}
131131

@@ -149,34 +149,34 @@ func TestWinCredHelperRetrieveStrict(t *testing.T) {
149149
{"https://foobar.docker.io:1234", "https://foobar.docker.io:5678"},
150150

151151
// non-matching ports TODO is this desired behavior? The other way round does work
152-
//{"https://foobar.docker.io", "https://foobar.docker.io:5678"},
152+
// {"https://foobar.docker.io", "https://foobar.docker.io:5678"},
153153

154154
// non-matching paths
155155
{"https://foobar.docker.io:1234/one/two", "https://foobar.docker.io:1234/five/six"},
156156
}
157157

158158
helper := Wincred{}
159159
defer func() {
160-
for _, te := range tests {
161-
helper.Delete(te.storeURL)
160+
for _, tc := range tests {
161+
helper.Delete(tc.storeURL)
162162
}
163163
}()
164164

165165
// Clean store before testing.
166-
for _, te := range tests {
167-
helper.Delete(te.storeURL)
166+
for _, tc := range tests {
167+
helper.Delete(tc.storeURL)
168168
}
169169

170-
for _, te := range tests {
171-
c := &credentials.Credentials{ServerURL: te.storeURL, Username: "hello", Secret: "world"}
170+
for _, tc := range tests {
171+
c := &credentials.Credentials{ServerURL: tc.storeURL, Username: "hello", Secret: "world"}
172172
if err := helper.Add(c); err != nil {
173-
t.Errorf("Error: failed to store secret for URL %q: %s", te.storeURL, err)
173+
t.Errorf("Error: failed to store secret for URL %q: %s", tc.storeURL, err)
174174
continue
175175
}
176-
if _, _, err := helper.Get(te.readURL); err == nil {
177-
t.Errorf("Error: managed to read secret for URL %q using %q, but should not be able to", te.storeURL, te.readURL)
176+
if _, _, err := helper.Get(tc.readURL); err == nil {
177+
t.Errorf("Error: managed to read secret for URL %q using %q, but should not be able to", tc.storeURL, tc.readURL)
178178
}
179-
helper.Delete(te.storeURL)
179+
helper.Delete(tc.storeURL)
180180
}
181181
}
182182

@@ -198,39 +198,39 @@ func TestWinCredHelperStoreRetrieve(t *testing.T) {
198198

199199
helper := Wincred{}
200200
defer func() {
201-
for _, te := range tests {
202-
helper.Delete(te.url)
201+
for _, tc := range tests {
202+
helper.Delete(tc.url)
203203
}
204204
}()
205205

206206
// Clean store before testing.
207-
for _, te := range tests {
208-
helper.Delete(te.url)
207+
for _, tc := range tests {
208+
helper.Delete(tc.url)
209209
}
210210

211211
// Note that we don't delete between individual tests here, to verify that
212212
// subsequent stores/overwrites don't affect storing / retrieving secrets.
213-
for i, te := range tests {
213+
for i, tc := range tests {
214214
c := &credentials.Credentials{
215-
ServerURL: te.url,
215+
ServerURL: tc.url,
216216
Username: fmt.Sprintf("user-%d", i),
217217
Secret: fmt.Sprintf("secret-%d", i),
218218
}
219219

220220
if err := helper.Add(c); err != nil {
221-
t.Errorf("Error: failed to store secret for URL: %s: %s", te.url, err)
221+
t.Errorf("Error: failed to store secret for URL: %s: %s", tc.url, err)
222222
continue
223223
}
224-
user, secret, err := helper.Get(te.url)
224+
user, secret, err := helper.Get(tc.url)
225225
if err != nil {
226-
t.Errorf("Error: failed to read secret for URL %q: %s", te.url, err)
226+
t.Errorf("Error: failed to read secret for URL %q: %s", tc.url, err)
227227
continue
228228
}
229229
if user != c.Username {
230-
t.Errorf("Error: expected username %s, got username %s for URL: %s", c.Username, user, te.url)
230+
t.Errorf("Error: expected username %s, got username %s for URL: %s", c.Username, user, tc.url)
231231
}
232232
if secret != c.Secret {
233-
t.Errorf("Error: expected secret %s, got secret %s for URL: %s", c.Secret, secret, te.url)
233+
t.Errorf("Error: expected secret %s, got secret %s for URL: %s", c.Secret, secret, tc.url)
234234
}
235235
}
236236
}

0 commit comments

Comments
 (0)