(t *testing.T)
| 371 | } |
| 372 | |
| 373 | func TestAPI_PaginateIgnoredForPOST(t *testing.T) { |
| 374 | // --paginate should be a no-op for non-GET methods (no pagination |
| 375 | // semantic for POST/PUT/DELETE). Single call expected. |
| 376 | called := 0 |
| 377 | svc := &fakeAPISvc{do: func(method, path string, _ any) (*http.Response, error) { |
| 378 | called++ |
| 379 | return &http.Response{ |
| 380 | StatusCode: 200, |
| 381 | Body: io.NopCloser(bytes.NewReader([]byte(`{"success":true,"data":[],"total":5,"page":1,"page_size":2}`))), |
| 382 | Header: make(http.Header), |
| 383 | }, nil |
| 384 | }} |
| 385 | |
| 386 | _, _ = iostreams.SetForTest(t) |
| 387 | |
| 388 | opts := &Options{Input: "-", StdinReader: strings.NewReader(`{"name":"foo"}`)} |
| 389 | if err := runAPI(context.Background(), opts, &cmdutil.FormatOptions{Mode: cmdutil.FormatJSON}, svc, "POST", "/api/v1/knowledge-base", true); err != nil { |
| 390 | t.Fatalf("runAPI: %v", err) |
| 391 | } |
| 392 | if called != 1 { |
| 393 | t.Errorf("called %d times, want 1 (POST should not paginate)", called) |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | func TestAPI_PaginateNoMetadataPassesThrough(t *testing.T) { |
| 398 | // If response doesn't look paginated (no total/page/page_size), --paginate |
nothing calls this directly
no test coverage detected