Skip to content

Commit 0dd6f7f

Browse files
committed
cil/config/credentials: remove newStore() test-utility
This function was names slightly confusing, as it returns a fakeStore, and it didn't do any constructing, so didn't provide value above just constructing the type. I'm planning to add more functionality to the fakeStore, but don't want to maintain a full-fledged constructor for all of that, so let's remove this utility. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 0ab0eca commit 0dd6f7f

2 files changed

Lines changed: 23 additions & 27 deletions

File tree

cli/config/credentials/file_store_test.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ func (f *fakeStore) GetFilename() string {
2424
return "/tmp/docker-fakestore"
2525
}
2626

27-
func newStore(auths map[string]types.AuthConfig) store {
28-
return &fakeStore{configs: auths}
29-
}
30-
3127
func TestFileStoreAddCredentials(t *testing.T) {
32-
f := newStore(make(map[string]types.AuthConfig))
28+
f := &fakeStore{configs: map[string]types.AuthConfig{}}
3329

3430
s := NewFileStore(f)
3531
auth := types.AuthConfig{
@@ -47,13 +43,13 @@ func TestFileStoreAddCredentials(t *testing.T) {
4743
}
4844

4945
func TestFileStoreGet(t *testing.T) {
50-
f := newStore(map[string]types.AuthConfig{
46+
f := &fakeStore{configs: map[string]types.AuthConfig{
5147
"https://example.com": {
5248
Auth: "super_secret_token",
5349
Email: "foo@example.com",
5450
ServerAddress: "https://example.com",
5551
},
56-
})
52+
}}
5753

5854
s := NewFileStore(f)
5955
a, err := s.Get("https://example.com")
@@ -71,7 +67,7 @@ func TestFileStoreGet(t *testing.T) {
7167
func TestFileStoreGetAll(t *testing.T) {
7268
s1 := "https://example.com"
7369
s2 := "https://example2.example.com"
74-
f := newStore(map[string]types.AuthConfig{
70+
f := &fakeStore{configs: map[string]types.AuthConfig{
7571
s1: {
7672
Auth: "super_secret_token",
7773
Email: "foo@example.com",
@@ -82,7 +78,7 @@ func TestFileStoreGetAll(t *testing.T) {
8278
Email: "foo@example2.com",
8379
ServerAddress: "https://example2.example.com",
8480
},
85-
})
81+
}}
8682

8783
s := NewFileStore(f)
8884
as, err := s.GetAll()
@@ -107,13 +103,13 @@ func TestFileStoreGetAll(t *testing.T) {
107103
}
108104

109105
func TestFileStoreErase(t *testing.T) {
110-
f := newStore(map[string]types.AuthConfig{
106+
f := &fakeStore{configs: map[string]types.AuthConfig{
111107
"https://example.com": {
112108
Auth: "super_secret_token",
113109
Email: "foo@example.com",
114110
ServerAddress: "https://example.com",
115111
},
116-
})
112+
}}
117113

118114
s := NewFileStore(f)
119115
err := s.Erase("https://example.com")

cli/config/credentials/native_store_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func mockCommandFn(args ...string) client.Program {
9191
}
9292

9393
func TestNativeStoreAddCredentials(t *testing.T) {
94-
f := newStore(make(map[string]types.AuthConfig))
94+
f := &fakeStore{configs: map[string]types.AuthConfig{}}
9595
s := &nativeStore{
9696
programFunc: mockCommandFn,
9797
fileStore: NewFileStore(f),
@@ -116,7 +116,7 @@ func TestNativeStoreAddCredentials(t *testing.T) {
116116
}
117117

118118
func TestNativeStoreAddInvalidCredentials(t *testing.T) {
119-
f := newStore(make(map[string]types.AuthConfig))
119+
f := &fakeStore{configs: map[string]types.AuthConfig{}}
120120
s := &nativeStore{
121121
programFunc: mockCommandFn,
122122
fileStore: NewFileStore(f),
@@ -132,11 +132,11 @@ func TestNativeStoreAddInvalidCredentials(t *testing.T) {
132132
}
133133

134134
func TestNativeStoreGet(t *testing.T) {
135-
f := newStore(map[string]types.AuthConfig{
135+
f := &fakeStore{configs: map[string]types.AuthConfig{
136136
validServerAddress: {
137137
Email: "foo@example.com",
138138
},
139-
})
139+
}}
140140
s := &nativeStore{
141141
programFunc: mockCommandFn,
142142
fileStore: NewFileStore(f),
@@ -154,11 +154,11 @@ func TestNativeStoreGet(t *testing.T) {
154154
}
155155

156156
func TestNativeStoreGetIdentityToken(t *testing.T) {
157-
f := newStore(map[string]types.AuthConfig{
157+
f := &fakeStore{configs: map[string]types.AuthConfig{
158158
validServerAddress2: {
159159
Email: "foo@example2.com",
160160
},
161-
})
161+
}}
162162

163163
s := &nativeStore{
164164
programFunc: mockCommandFn,
@@ -176,11 +176,11 @@ func TestNativeStoreGetIdentityToken(t *testing.T) {
176176
}
177177

178178
func TestNativeStoreGetAll(t *testing.T) {
179-
f := newStore(map[string]types.AuthConfig{
179+
f := &fakeStore{configs: map[string]types.AuthConfig{
180180
validServerAddress: {
181181
Email: "foo@example.com",
182182
},
183-
})
183+
}}
184184

185185
s := &nativeStore{
186186
programFunc: mockCommandFn,
@@ -217,11 +217,11 @@ func TestNativeStoreGetAll(t *testing.T) {
217217
}
218218

219219
func TestNativeStoreGetMissingCredentials(t *testing.T) {
220-
f := newStore(map[string]types.AuthConfig{
220+
f := &fakeStore{configs: map[string]types.AuthConfig{
221221
validServerAddress: {
222222
Email: "foo@example.com",
223223
},
224-
})
224+
}}
225225

226226
s := &nativeStore{
227227
programFunc: mockCommandFn,
@@ -232,11 +232,11 @@ func TestNativeStoreGetMissingCredentials(t *testing.T) {
232232
}
233233

234234
func TestNativeStoreGetInvalidAddress(t *testing.T) {
235-
f := newStore(map[string]types.AuthConfig{
235+
f := &fakeStore{configs: map[string]types.AuthConfig{
236236
validServerAddress: {
237237
Email: "foo@example.com",
238238
},
239-
})
239+
}}
240240

241241
s := &nativeStore{
242242
programFunc: mockCommandFn,
@@ -247,11 +247,11 @@ func TestNativeStoreGetInvalidAddress(t *testing.T) {
247247
}
248248

249249
func TestNativeStoreErase(t *testing.T) {
250-
f := newStore(map[string]types.AuthConfig{
250+
f := &fakeStore{configs: map[string]types.AuthConfig{
251251
validServerAddress: {
252252
Email: "foo@example.com",
253253
},
254-
})
254+
}}
255255

256256
s := &nativeStore{
257257
programFunc: mockCommandFn,
@@ -263,11 +263,11 @@ func TestNativeStoreErase(t *testing.T) {
263263
}
264264

265265
func TestNativeStoreEraseInvalidAddress(t *testing.T) {
266-
f := newStore(map[string]types.AuthConfig{
266+
f := &fakeStore{configs: map[string]types.AuthConfig{
267267
validServerAddress: {
268268
Email: "foo@example.com",
269269
},
270-
})
270+
}}
271271

272272
s := &nativeStore{
273273
programFunc: mockCommandFn,

0 commit comments

Comments
 (0)