MCPcopy Create free account
hub / github.com/docker/cli / TestGetAllCredentialsCredsStore

Function TestGetAllCredentialsCredsStore

cli/config/configfile/file_test.go:216–240  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

214}
215
216func TestGetAllCredentialsCredsStore(t *testing.T) {
217 configFile := New("filename")
218 configFile.CredentialsStore = "test_creds_store"
219 testRegistryHostname := "example.com"
220 expectedAuth := types.AuthConfig{
221 Username: "user",
222 Password: "pass",
223 }
224
225 testCredsStore := NewMockNativeStore(map[string]types.AuthConfig{testRegistryHostname: expectedAuth}, nil)
226
227 tmpNewNativeStore := newNativeStore
228 defer func() { newNativeStore = tmpNewNativeStore }()
229 newNativeStore = func(configFile *ConfigFile, helperSuffix string) credentials.Store {
230 return testCredsStore
231 }
232
233 authConfigs, err := configFile.GetAllCredentials()
234 assert.NilError(t, err)
235
236 expected := make(map[string]types.AuthConfig)
237 expected[testRegistryHostname] = expectedAuth
238 assert.Check(t, is.DeepEqual(expected, authConfigs))
239 assert.Check(t, is.Equal(1, testCredsStore.(*mockNativeStore).GetAllCallCount))
240}
241
242func TestGetAllCredentialsCredStoreErrorHandling(t *testing.T) {
243 const (

Callers

nothing calls this directly

Calls 3

NewMockNativeStoreFunction · 0.85
GetAllCredentialsMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…