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

Function TestIssueView_nontty_Issues2AllFields

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

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected