(t *testing.T)
| 596 | } |
| 597 | |
| 598 | func TestSearchService_Labels(t *testing.T) { |
| 599 | t.Parallel() |
| 600 | client, mux, _ := setup(t) |
| 601 | |
| 602 | mux.HandleFunc("/search/labels", func(w http.ResponseWriter, r *http.Request) { |
| 603 | testMethod(t, r, "GET") |
| 604 | testFormValues(t, r, values{ |
| 605 | "repository_id": "1234", |
| 606 | "q": "blah", |
| 607 | "sort": "updated", |
| 608 | "order": "desc", |
| 609 | "page": "2", |
| 610 | "per_page": "2", |
| 611 | }) |
| 612 | |
| 613 | fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"id": 1234, "name":"bug", "description": "some text"},{"id": 4567, "name":"feature"}]}`) |
| 614 | }) |
| 615 | |
| 616 | opts := &SearchOptions{Sort: "updated", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}} |
| 617 | ctx := t.Context() |
| 618 | result, _, err := client.Search.Labels(ctx, 1234, "blah", opts) |
| 619 | if err != nil { |
| 620 | t.Errorf("Search.Code returned error: %v", err) |
| 621 | } |
| 622 | |
| 623 | want := &LabelsSearchResult{ |
| 624 | Total: Ptr(4), |
| 625 | IncompleteResults: Ptr(false), |
| 626 | Labels: []*LabelResult{ |
| 627 | {ID: Ptr(int64(1234)), Name: Ptr("bug"), Description: Ptr("some text")}, |
| 628 | {ID: Ptr(int64(4567)), Name: Ptr("feature")}, |
| 629 | }, |
| 630 | } |
| 631 | if !cmp.Equal(result, want) { |
| 632 | t.Errorf("Search.Labels returned %+v, want %+v", result, want) |
| 633 | } |
| 634 | const methodName = "Labels" |
| 635 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 636 | got, resp, err := client.Search.Labels(ctx, 1234, "blah", opts) |
| 637 | if got != nil { |
| 638 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 639 | } |
| 640 | return resp, err |
| 641 | }) |
| 642 | } |
| 643 | |
| 644 | func TestSearchService_Labels_coverage(t *testing.T) { |
| 645 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…