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

Function TestIsNeedUserAuthorizationError

internal/auth/errors_test.go:12–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestIsNeedUserAuthorizationError(t *testing.T) {
13 t.Run("nil error", func(t *testing.T) {
14 if IsNeedUserAuthorizationError(nil) {
15 t.Fatal("expected nil error not to match")
16 }
17 })
18
19 t.Run("direct auth error", func(t *testing.T) {
20 if !IsNeedUserAuthorizationError(&NeedAuthorizationError{UserOpenId: "u_1"}) {
21 t.Fatal("expected direct NeedAuthorizationError to match")
22 }
23 })
24
25 t.Run("typed missing-UAT error carries sentinel in cause", func(t *testing.T) {
26 // The typed constructor preserves the legacy sentinel in the Cause
27 // chain, so errors.As traverses into it.
28 if !IsNeedUserAuthorizationError(NewNeedUserAuthorizationError("u_1")) {
29 t.Fatal("expected typed missing-UAT error to match via its cause chain")
30 }
31 })
32
33 t.Run("other error", func(t *testing.T) {
34 err := errs.NewNetworkError(errs.SubtypeNetworkTransport, "API call failed: timeout")
35 if IsNeedUserAuthorizationError(err) {
36 t.Fatal("expected unrelated error not to match")
37 }
38 })
39}

Callers

nothing calls this directly

Calls 4

NewNetworkErrorFunction · 0.92
RunMethod · 0.65

Tested by

no test coverage detected