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