(t *testing.T)
| 751 | } |
| 752 | |
| 753 | func Test_RepoMilestones(t *testing.T) { |
| 754 | tests := []struct { |
| 755 | state string |
| 756 | want string |
| 757 | wantErr bool |
| 758 | }{ |
| 759 | { |
| 760 | state: "open", |
| 761 | want: `"states":["OPEN"]`, |
| 762 | }, |
| 763 | { |
| 764 | state: "closed", |
| 765 | want: `"states":["CLOSED"]`, |
| 766 | }, |
| 767 | { |
| 768 | state: "all", |
| 769 | want: `"states":["OPEN","CLOSED"]`, |
| 770 | }, |
| 771 | { |
| 772 | state: "invalid state", |
| 773 | wantErr: true, |
| 774 | }, |
| 775 | } |
| 776 | for _, tt := range tests { |
| 777 | var query string |
| 778 | reg := &httpmock.Registry{} |
| 779 | reg.Register(httpmock.MatchAny, func(req *http.Request) (*http.Response, error) { |
| 780 | buf := new(strings.Builder) |
| 781 | _, err := io.Copy(buf, req.Body) |
| 782 | if err != nil { |
| 783 | return nil, err |
| 784 | } |
| 785 | query = buf.String() |
| 786 | return httpmock.StringResponse("{}")(req) |
| 787 | }) |
| 788 | client := newTestClient(reg) |
| 789 | |
| 790 | _, err := RepoMilestones(client, ghrepo.New("OWNER", "REPO"), tt.state) |
| 791 | if (err != nil) != tt.wantErr { |
| 792 | t.Errorf("RepoMilestones() error = %v, wantErr %v", err, tt.wantErr) |
| 793 | return |
| 794 | } |
| 795 | if !strings.Contains(query, tt.want) { |
| 796 | t.Errorf("query does not contain %v", tt.want) |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | func TestDisplayName(t *testing.T) { |
| 802 | tests := []struct { |
nothing calls this directly
no test coverage detected