MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / TestClientPaginateVariousPageSizes

Function TestClientPaginateVariousPageSizes

mcp/client_test.go:186–210  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

184}
185
186func TestClientPaginateVariousPageSizes(t *testing.T) {
187 ctx := context.Background()
188 for i := 1; i < len(allItems)+1; i++ {
189 testname := fmt.Sprintf("PageSize=%d", i)
190 t.Run(testname, func(t *testing.T) {
191 results := generatePaginatedResults(allItems, i)
192 listFunc := func(ctx context.Context, params *ListTestParams) (*ListTestResult, error) {
193 res := results[0]
194 results = results[1:]
195 return res, nil
196 }
197 var gotItems []*Item
198 seq := paginate(ctx, &ListTestParams{}, listFunc, func(r *ListTestResult) []*Item { return r.Items })
199 for item, err := range seq {
200 if err != nil {
201 t.Fatalf("paginate() unexpected error during iteration: %v", err)
202 }
203 gotItems = append(gotItems, item)
204 }
205 if diff := cmp.Diff(allItems, gotItems, cmpopts.IgnoreUnexported(jsonschema.Schema{})); diff != "" {
206 t.Fatalf("paginate() mismatch (-want +got):\n%s", diff)
207 }
208 })
209 }
210}
211
212func TestClientCapabilities(t *testing.T) {
213 testCases := []struct {

Callers

nothing calls this directly

Calls 3

generatePaginatedResultsFunction · 0.85
paginateFunction · 0.85
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…