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

Function TestStreamPages_NonBatchAPI_NoArrayField

internal/client/client_test.go:110–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestStreamPages_NonBatchAPI_NoArrayField(t *testing.T) {
111 rt := roundTripFunc(func(req *http.Request) (*http.Response, error) {
112 return jsonResponse(map[string]interface{}{
113 "code": 0, "msg": "ok",
114 "data": map[string]interface{}{
115 "user_id": "u123",
116 "name": "Test User",
117 },
118 }), nil
119 })
120
121 ac, errBuf := newTestAPIClient(t, rt)
122
123 result, hasItems, err := ac.StreamPages(context.Background(), RawApiRequest{
124 Method: "GET",
125 URL: "/open-apis/contact/v3/users/u123",
126 As: "bot",
127 }, func(items []interface{}) error {
128 t.Error("onItems should not be called for non-batch API")
129 return nil
130 }, PaginationOptions{})
131
132 if err != nil {
133 t.Fatalf("unexpected error: %v", err)
134 }
135 if hasItems {
136 t.Error("expected hasItems=false for non-batch API")
137 }
138 if strings.Contains(errBuf.String(), "[pagination] streamed") {
139 t.Error("expected no pagination summary log for non-batch API")
140 }
141 if result == nil {
142 t.Fatal("expected non-nil result")
143 }
144 resultMap, ok := result.(map[string]interface{})
145 if !ok {
146 t.Fatal("expected result to be a map")
147 }
148 data, _ := resultMap["data"].(map[string]interface{})
149 if data["user_id"] != "u123" {
150 t.Errorf("expected user_id=u123, got %v", data["user_id"])
151 }
152}
153
154func TestStreamPages_BatchAPI_WithArrayField(t *testing.T) {
155 rt := roundTripFunc(func(req *http.Request) (*http.Response, error) {

Callers

nothing calls this directly

Calls 7

jsonResponseFunction · 0.85
newTestAPIClientFunction · 0.85
roundTripFuncFuncType · 0.70
StreamPagesMethod · 0.45
ErrorMethod · 0.45
ContainsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected