(t *testing.T)
| 202 | } |
| 203 | |
| 204 | func TestServerPaginateVariousPageSizes(t *testing.T) { |
| 205 | fs := newFeatureSet(func(t *testItem) string { return t.Name }) |
| 206 | fs.add(allTestItems...) |
| 207 | // Try all possible page sizes, ensuring we get the correct list of items. |
| 208 | for pageSize := 1; pageSize < len(allTestItems)+1; pageSize++ { |
| 209 | var gotItems []*testItem |
| 210 | var nextCursor string |
| 211 | wantChunks := slices.Collect(slices.Chunk(allTestItems, pageSize)) |
| 212 | index := 0 |
| 213 | // Iterate through all pages, comparing sub-slices to the paginated list. |
| 214 | for { |
| 215 | params := &testListParams{Cursor: nextCursor} |
| 216 | gotResult, err := paginateList(fs, pageSize, params, &testListResult{}, func(res *testListResult, items []*testItem) { |
| 217 | res.Items = items |
| 218 | }) |
| 219 | if err != nil { |
| 220 | t.Fatalf("paginateList() unexpected error for pageSize %d, cursor %q: %v", pageSize, nextCursor, err) |
| 221 | } |
| 222 | if diff := cmp.Diff(wantChunks[index], gotResult.Items); diff != "" { |
| 223 | t.Errorf("paginateList mismatch (-want +got):\n%s", diff) |
| 224 | } |
| 225 | gotItems = append(gotItems, gotResult.Items...) |
| 226 | nextCursor = gotResult.NextCursor |
| 227 | if nextCursor == "" { |
| 228 | break |
| 229 | } |
| 230 | index++ |
| 231 | } |
| 232 | |
| 233 | if len(gotItems) != len(allTestItems) { |
| 234 | t.Fatalf("paginateList() returned %d items, want %d", len(allTestItems), len(gotItems)) |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | func TestServerCapabilities(t *testing.T) { |
| 240 | tool := &Tool{Name: "t", InputSchema: &jsonschema.Schema{Type: "object"}} |
nothing calls this directly
no test coverage detected
searching dependent graphs…