MCPcopy
hub / github.com/larksuite/cli / TestLoginRequestedScopeCache_RoundTrip

Function TestLoginRequestedScopeCache_RoundTrip

cmd/auth/login_scope_cache_test.go:14–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func 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
41func TestLoadLoginRequestedScope_MissingReturnsEmpty(t *testing.T) {
42 setupLoginConfigDir(t)

Callers

nothing calls this directly

Calls 7

StatFunction · 0.92
setupLoginConfigDirFunction · 0.85
saveLoginRequestedScopeFunction · 0.85
loadLoginRequestedScopeFunction · 0.85
loginScopeCachePathFunction · 0.85
IsMethod · 0.80

Tested by

no test coverage detected