Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 292158c

Browse files
jonjohnsonjrthaJeztah
authored andcommitted
Add test case to cover non-empty auth entry
Signed-off-by: Jon Johnson <jonjohnson@google.com> (cherry picked from commit 415f608620df6e3160dfa67000994a4252f95b20) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> Upstream-commit: 41b01f1319b52055bd695d3e458c83724d4186ee Component: cli
1 parent 5caedcf commit 292158c

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

components/cli/cli/config/configfile/file_test.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,23 +389,31 @@ func TestLoadFromReaderWithUsernamePassword(t *testing.T) {
389389
Username: "user",
390390
Password: "pass",
391391
}
392-
cf := ConfigFile{
393-
AuthConfigs: map[string]types.AuthConfig{
394-
"example.com/foo": want,
392+
393+
for _, tc := range []types.AuthConfig{
394+
want,
395+
types.AuthConfig{
396+
Auth: encodeAuth(&want),
395397
},
396-
}
398+
} {
399+
cf := ConfigFile{
400+
AuthConfigs: map[string]types.AuthConfig{
401+
"example.com/foo": tc,
402+
},
403+
}
397404

398-
b, err := json.Marshal(cf)
399-
assert.NilError(t, err)
405+
b, err := json.Marshal(cf)
406+
assert.NilError(t, err)
400407

401-
err = configFile.LoadFromReader(bytes.NewReader(b))
402-
assert.NilError(t, err)
408+
err = configFile.LoadFromReader(bytes.NewReader(b))
409+
assert.NilError(t, err)
403410

404-
got, err := configFile.GetAuthConfig("example.com/foo")
405-
assert.NilError(t, err)
411+
got, err := configFile.GetAuthConfig("example.com/foo")
412+
assert.NilError(t, err)
406413

407-
assert.Check(t, is.DeepEqual(want.Username, got.Username))
408-
assert.Check(t, is.DeepEqual(want.Password, got.Password))
414+
assert.Check(t, is.DeepEqual(want.Username, got.Username))
415+
assert.Check(t, is.DeepEqual(want.Password, got.Password))
416+
}
409417
}
410418

411419
func TestCheckKubernetesConfigurationRaiseAnErrorOnInvalidValue(t *testing.T) {

0 commit comments

Comments
 (0)