(t *testing.T)
| 55 | } |
| 56 | |
| 57 | func 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 | |
| 93 | func TestRunLogin(t *testing.T) { |
| 94 | testCases := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…