(t *testing.T)
| 657 | } |
| 658 | |
| 659 | func Test_RepoMilestones(t *testing.T) { |
| 660 | tests := []struct { |
| 661 | state string |
| 662 | want string |
| 663 | wantErr bool |
| 664 | }{ |
| 665 | { |
| 666 | state: "open", |
| 667 | want: `"states":["OPEN"]`, |
| 668 | }, |
| 669 | { |
| 670 | state: "closed", |
| 671 | want: `"states":["CLOSED"]`, |
| 672 | }, |
| 673 | { |
| 674 | state: "all", |
| 675 | want: `"states":["OPEN","CLOSED"]`, |
| 676 | }, |
| 677 | { |
| 678 | state: "invalid state", |
| 679 | wantErr: true, |
| 680 | }, |
| 681 | } |
| 682 | for _, tt := range tests { |
| 683 | var query string |
| 684 | reg := &httpmock.Registry{} |
| 685 | reg.Register(httpmock.MatchAny, func(req *http.Request) (*http.Response, error) { |
| 686 | buf := new(strings.Builder) |
| 687 | _, err := io.Copy(buf, req.Body) |
| 688 | if err != nil { |
| 689 | return nil, err |
| 690 | } |
| 691 | query = buf.String() |
| 692 | return httpmock.StringResponse("{}")(req) |
| 693 | }) |
| 694 | client := newTestClient(reg) |
| 695 | |
| 696 | _, err := RepoMilestones(client, ghrepo.New("OWNER", "REPO"), tt.state) |
| 697 | if (err != nil) != tt.wantErr { |
| 698 | t.Errorf("RepoMilestones() error = %v, wantErr %v", err, tt.wantErr) |
| 699 | return |
| 700 | } |
| 701 | if !strings.Contains(query, tt.want) { |
| 702 | t.Errorf("query does not contain %v", tt.want) |
| 703 | } |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | func TestDisplayName(t *testing.T) { |
| 708 | tests := []struct { |
nothing calls this directly
no test coverage detected