MCPcopy Create free account
hub / github.com/cli/cli / Test_RepoMilestones

Function Test_RepoMilestones

api/queries_repo_test.go:753–799  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

751}
752
753func 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
801func TestDisplayName(t *testing.T) {
802 tests := []struct {

Callers

nothing calls this directly

Calls 9

RegisterMethod · 0.95
StringResponseFunction · 0.92
NewFunction · 0.92
newTestClientFunction · 0.85
RepoMilestonesFunction · 0.85
ContainsMethod · 0.80
StringMethod · 0.65
ErrorfMethod · 0.65
CopyMethod · 0.45

Tested by

no test coverage detected