MCPcopy Create free account
hub / github.com/basecamp/hey-cli / TestSaveLoadRoundTrip

Function TestSaveLoadRoundTrip

internal/auth/store_test.go:15–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13}
14
15func TestSaveLoadRoundTrip(t *testing.T) {
16 s := testStore(t)
17 origin := "https://app.hey.com"
18 creds := &Credentials{
19 AccessToken: "access-123",
20 RefreshToken: "refresh-456",
21 ExpiresAt: 1700000000,
22 OAuthType: "oauth",
23 }
24
25 if err := s.Save(origin, creds); err != nil {
26 t.Fatalf("Save: %v", err)
27 }
28
29 loaded, err := s.Load(origin)
30 if err != nil {
31 t.Fatalf("Load: %v", err)
32 }
33
34 if loaded.AccessToken != creds.AccessToken {
35 t.Errorf("AccessToken = %q, want %q", loaded.AccessToken, creds.AccessToken)
36 }
37 if loaded.RefreshToken != creds.RefreshToken {
38 t.Errorf("RefreshToken = %q, want %q", loaded.RefreshToken, creds.RefreshToken)
39 }
40 if loaded.ExpiresAt != creds.ExpiresAt {
41 t.Errorf("ExpiresAt = %d, want %d", loaded.ExpiresAt, creds.ExpiresAt)
42 }
43 if loaded.OAuthType != creds.OAuthType {
44 t.Errorf("OAuthType = %q, want %q", loaded.OAuthType, creds.OAuthType)
45 }
46}
47
48func TestLoadNotFound(t *testing.T) {
49 s := testStore(t)

Callers

nothing calls this directly

Calls 3

testStoreFunction · 0.85
LoadMethod · 0.80
SaveMethod · 0.45

Tested by

no test coverage detected