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

Function Test_RepoMilestones

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

Source from the content-addressed store, hash-verified

740}
741
742func 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
790func TestDisplayName(t *testing.T) {
791 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