(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestLoginRequestedScopeCache_RoundTrip(t *testing.T) { |
| 15 | setupLoginConfigDir(t) |
| 16 | |
| 17 | deviceCode := "device/code:123" |
| 18 | requestedScope := "im:message:send im:message:reply" |
| 19 | |
| 20 | if err := saveLoginRequestedScope(deviceCode, requestedScope); err != nil { |
| 21 | t.Fatalf("saveLoginRequestedScope() error = %v", err) |
| 22 | } |
| 23 | got, err := loadLoginRequestedScope(deviceCode) |
| 24 | if err != nil { |
| 25 | t.Fatalf("loadLoginRequestedScope() error = %v", err) |
| 26 | } |
| 27 | if got != requestedScope { |
| 28 | t.Fatalf("requestedScope = %q, want %q", got, requestedScope) |
| 29 | } |
| 30 | if _, err := vfs.Stat(loginScopeCachePath(deviceCode)); err != nil { |
| 31 | t.Fatalf("Stat(cachePath) error = %v", err) |
| 32 | } |
| 33 | if err := removeLoginRequestedScope(deviceCode); err != nil { |
| 34 | t.Fatalf("removeLoginRequestedScope() error = %v", err) |
| 35 | } |
| 36 | if _, err := vfs.Stat(loginScopeCachePath(deviceCode)); !errors.Is(err, os.ErrNotExist) { |
| 37 | t.Fatalf("Stat(cachePath) error = %v, want not exist", err) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func TestLoadLoginRequestedScope_MissingReturnsEmpty(t *testing.T) { |
| 42 | setupLoginConfigDir(t) |
nothing calls this directly
no test coverage detected