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

Function TestIssueView_tty_Issues2AllFields

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

Source from the content-addressed store, hash-verified

719}
720
721func TestIssueView_tty_Issues2AllFields(t *testing.T) {
722 ios, _, stdout, stderr := iostreams.Test()
723 ios.SetStdoutTTY(true)
724 ios.SetStdinTTY(true)
725 ios.SetStderrTTY(true)
726
727 httpReg := &httpmock.Registry{}
728 defer httpReg.Verify(t)
729
730 httpReg.Register(
731 httpmock.GraphQL(`query IssueByNumber\b`),
732 httpmock.StringResponse(issueResponseAllIssues2Fields()),
733 )
734 mockEmptyV2ProjectItems(t, httpReg)
735
736 opts := ViewOptions{
737 IO: ios,
738 Now: func() time.Time {
739 t, _ := time.Parse(time.RFC822, "03 Nov 24 15:04 UTC")
740 return t
741 },
742 HttpClient: func() (*http.Client, error) {
743 return &http.Client{Transport: httpReg}, nil
744 },
745 BaseRepo: func() (ghrepo.Interface, error) {
746 return ghrepo.New("OWNER", "REPO"), nil
747 },
748 IssueNumber: 123,
749 }
750
751 err := viewRun(&opts)
752 require.NoError(t, err)
753
754 assert.Equal(t, "", stderr.String())
755
756 out := stdout.String()
757
758 // Title
759 assert.Contains(t, out, "Implement OAuth flow")
760 assert.Contains(t, out, "OWNER/REPO#123")
761
762 // State line includes issue type prefix
763 assert.Contains(t, out, "Bug · Open")
764
765 // Type metadata row
766 assert.Contains(t, out, "Type:")
767 assert.Contains(t, out, "Bug")
768
769 // Parent metadata row
770 assert.Contains(t, out, "Parent:")
771 assert.Contains(t, out, "OWNER/REPO#100 Epic: Authentication overhaul")
772
773 // Blocked by metadata row
774 assert.Contains(t, out, "Blocked by:")
775 assert.Contains(t, out, "OWNER/REPO#200 API rate limiting")
776
777 // Blocking metadata row
778 assert.Contains(t, out, "Blocking:")

Callers

nothing calls this directly

Calls 15

VerifyMethod · 0.95
RegisterMethod · 0.95
TestFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NewFunction · 0.92
mockEmptyV2ProjectItemsFunction · 0.85
SetStdoutTTYMethod · 0.80
SetStdinTTYMethod · 0.80
SetStderrTTYMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected