MCPcopy
hub / github.com/cli/cli / TestIssueView_nontty_Issues2AllFields

Function TestIssueView_nontty_Issues2AllFields

pkg/cmd/issue/view/view_test.go:784–824  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

782}
783
784func TestIssueView_nontty_Issues2AllFields(t *testing.T) {
785 ios, _, stdout, stderr := iostreams.Test()
786
787 httpReg := &httpmock.Registry{}
788 defer httpReg.Verify(t)
789
790 httpReg.Register(
791 httpmock.GraphQL(`query IssueByNumber\b`),
792 httpmock.StringResponse(issueResponseAllIssues2Fields()),
793 )
794 mockEmptyV2ProjectItems(t, httpReg)
795
796 opts := ViewOptions{
797 IO: ios,
798 Now: func() time.Time {
799 t, _ := time.Parse(time.RFC822, "03 Nov 24 15:04 UTC")
800 return t
801 },
802 HttpClient: func() (*http.Client, error) {
803 return &http.Client{Transport: httpReg}, nil
804 },
805 BaseRepo: func() (ghrepo.Interface, error) {
806 return ghrepo.New("OWNER", "REPO"), nil
807 },
808 IssueNumber: 123,
809 }
810
811 err := viewRun(&opts)
812 require.NoError(t, err)
813
814 assert.Equal(t, "", stderr.String())
815
816 out := stdout.String()
817
818 assert.Contains(t, out, "issue-type:\tBug\n")
819 assert.Contains(t, out, "parent:\tOWNER/REPO#100\n")
820 assert.Contains(t, out, "sub-issues:\tOWNER/REPO#101, OWNER/REPO#102\n")
821 assert.Contains(t, out, "sub-issues-completed:\t1/2\n")
822 assert.Contains(t, out, "blocked-by:\tOWNER/REPO#200\n")
823 assert.Contains(t, out, "blocking:\tOWNER/REPO#300\n")
824}
825
826func TestIssueView_tty_Issues2NoFields(t *testing.T) {
827 ios, _, stdout, stderr := iostreams.Test()

Callers

nothing calls this directly

Calls 12

VerifyMethod · 0.95
RegisterMethod · 0.95
TestFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NewFunction · 0.92
mockEmptyV2ProjectItemsFunction · 0.85
EqualMethod · 0.80
ContainsMethod · 0.80
viewRunFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected