(t *testing.T)
| 52 | } |
| 53 | |
| 54 | func TestReadTokensReadsTokenMap(t *testing.T) { |
| 55 | authFile := filepath.Join(t.TempDir(), "auth.json") |
| 56 | if err := os.WriteFile(authFile, []byte(`{"":{"personal":"personal-token"},"api.example.com":{"teamManage":"team-token"}}`), 0600); err != nil { |
| 57 | t.Fatal(err) |
| 58 | } |
| 59 | |
| 60 | tokens, err := readTokens(authFile) |
| 61 | if err != nil { |
| 62 | t.Fatal(err) |
| 63 | } |
| 64 | |
| 65 | if tokens[""][tokenPersonal].AccessToken != "personal-token" { |
| 66 | t.Fatalf("expected personal token, got %q", tokens[""][tokenPersonal].AccessToken) |
| 67 | } |
| 68 | if tokens["api.example.com"][tokenTeamManage].AccessToken != "team-token" { |
| 69 | t.Fatalf("expected team token, got %q", tokens["api.example.com"][tokenTeamManage].AccessToken) |
| 70 | } |
| 71 | if tokens[""][tokenPersonal].RefreshToken != "" { |
| 72 | t.Fatalf("expected legacy personal token to have no refresh token, got %q", tokens[""][tokenPersonal].RefreshToken) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func TestReadTokensReadsRefreshableCredentials(t *testing.T) { |
| 77 | authFile := filepath.Join(t.TempDir(), "auth.json") |
nothing calls this directly
no test coverage detected