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

Function TestBuildAPIError_NilAndZeroCode

internal/errclass/classify_test.go:48–60  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestBuildAPIError_NilAndZeroCode(t *testing.T) {
49 if got := errclass.BuildAPIError(nil, errclass.ClassifyContext{}); got != nil {
50 t.Errorf("nil resp should return nil error, got %v", got)
51 }
52 if got := errclass.BuildAPIError(map[string]any{"code": 0, "msg": "ok"}, errclass.ClassifyContext{}); got != nil {
53 t.Errorf("code=0 should return nil error, got %v", got)
54 }
55 // json.Number 0 path (real-world SDK decodes with UseNumber)
56 resp := map[string]any{"code": json.Number("0"), "msg": "ok"}
57 if got := errclass.BuildAPIError(resp, errclass.ClassifyContext{}); got != nil {
58 t.Errorf("json.Number(0) should return nil error, got %v", got)
59 }
60}
61
62// matchesTypedError reports whether err is the typed-error variant identified by
63// wantTyped (e.g. "ValidationError" → *errs.ValidationError). Used by the

Callers

nothing calls this directly

Calls 1

BuildAPIErrorFunction · 0.92

Tested by

no test coverage detected