(t *testing.T)
| 214 | } |
| 215 | |
| 216 | func 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 | |
| 242 | func TestGetAllCredentialsCredStoreErrorHandling(t *testing.T) { |
| 243 | const ( |
nothing calls this directly
no test coverage detected
searching dependent graphs…