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

Function TestLoginWithCredStoreCreds

cli/command/registry/login_test.go:57–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestLoginWithCredStoreCreds(t *testing.T) {
58 testCases := []struct {
59 inputAuthConfig registrytypes.AuthConfig
60 expectedErr string
61 expectedMsg string
62 expectedErrMsg string
63 }{
64 {
65 inputAuthConfig: registrytypes.AuthConfig{},
66 },
67 {
68 inputAuthConfig: registrytypes.AuthConfig{
69 Username: unknownUser,
70 },
71 expectedErr: errUnknownUser,
72 expectedErrMsg: fmt.Sprintf("Login did not succeed, error: %s\n", errUnknownUser),
73 },
74 }
75 ctx := context.Background()
76 tmpDir := t.TempDir()
77 cli := test.NewFakeCli(&fakeClient{})
78 cli.SetConfigFile(configfile.New(filepath.Join(tmpDir, "config.json")))
79 for _, tc := range testCases {
80 _, err := loginWithStoredCredentials(ctx, cli, tc.inputAuthConfig)
81 if tc.expectedErrMsg != "" {
82 assert.Check(t, is.Error(err, tc.expectedErr))
83 } else {
84 assert.NilError(t, err)
85 }
86 assert.Check(t, is.Equal(tc.expectedMsg, cli.OutBuffer().String()))
87 assert.Check(t, is.Contains(cli.ErrBuffer().String(), tc.expectedErrMsg))
88 cli.ErrBuffer().Reset()
89 cli.OutBuffer().Reset()
90 }
91}
92
93func TestRunLogin(t *testing.T) {
94 testCases := []struct {

Callers

nothing calls this directly

Calls 7

SetConfigFileMethod · 0.95
OutBufferMethod · 0.95
ErrBufferMethod · 0.95
ContainsMethod · 0.80
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…