(t *testing.T)
| 423 | } |
| 424 | |
| 425 | func TestSearchService_Users(t *testing.T) { |
| 426 | t.Parallel() |
| 427 | client, mux, _ := setup(t) |
| 428 | |
| 429 | mux.HandleFunc("/search/users", func(w http.ResponseWriter, r *http.Request) { |
| 430 | testMethod(t, r, "GET") |
| 431 | testFormValues(t, r, values{ |
| 432 | "q": "blah", |
| 433 | "sort": "forks", |
| 434 | "order": "desc", |
| 435 | "page": "2", |
| 436 | "per_page": "2", |
| 437 | }) |
| 438 | |
| 439 | fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"id":1},{"id":2}]}`) |
| 440 | }) |
| 441 | |
| 442 | opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}} |
| 443 | ctx := t.Context() |
| 444 | result, _, err := client.Search.Users(ctx, "blah", opts) |
| 445 | if err != nil { |
| 446 | t.Errorf("Search.Issues returned error: %v", err) |
| 447 | } |
| 448 | |
| 449 | want := &UsersSearchResult{ |
| 450 | Total: Ptr(4), |
| 451 | IncompleteResults: Ptr(false), |
| 452 | Users: []*User{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}}, |
| 453 | } |
| 454 | if !cmp.Equal(result, want) { |
| 455 | t.Errorf("Search.Users returned %+v, want %+v", result, want) |
| 456 | } |
| 457 | const methodName = "Users" |
| 458 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 459 | got, resp, err := client.Search.Users(ctx, "blah", opts) |
| 460 | if got != nil { |
| 461 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 462 | } |
| 463 | return resp, err |
| 464 | }) |
| 465 | } |
| 466 | |
| 467 | func TestSearchService_Users_coverage(t *testing.T) { |
| 468 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…