MCPcopy
hub / github.com/cli/cli / Test_RepoMilestones

Function Test_RepoMilestones

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

Source from the content-addressed store, hash-verified

657}
658
659func 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
707func TestDisplayName(t *testing.T) {
708 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
ErrorfMethod · 0.65
CopyMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected