MCPcopy
hub / github.com/cli/cli / TestIssueView_tty_Issues2NoFields

Function TestIssueView_tty_Issues2NoFields

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

Source from the content-addressed store, hash-verified

824}
825
826func TestIssueView_tty_Issues2NoFields(t *testing.T) {
827 ios, _, stdout, stderr := iostreams.Test()
828 ios.SetStdoutTTY(true)
829 ios.SetStdinTTY(true)
830 ios.SetStderrTTY(true)
831
832 httpReg := &httpmock.Registry{}
833 defer httpReg.Verify(t)
834
835 httpReg.Register(
836 httpmock.GraphQL(`query IssueByNumber\b`),
837 httpmock.StringResponse(issueResponseNoIssues2Fields()),
838 )
839 mockEmptyV2ProjectItems(t, httpReg)
840
841 opts := ViewOptions{
842 IO: ios,
843 Now: func() time.Time {
844 t, _ := time.Parse(time.RFC822, "03 Nov 24 15:04 UTC")
845 return t
846 },
847 HttpClient: func() (*http.Client, error) {
848 return &http.Client{Transport: httpReg}, nil
849 },
850 BaseRepo: func() (ghrepo.Interface, error) {
851 return ghrepo.New("OWNER", "REPO"), nil
852 },
853 IssueNumber: 456,
854 }
855
856 err := viewRun(&opts)
857 require.NoError(t, err)
858
859 assert.Equal(t, "", stderr.String())
860
861 out := stdout.String()
862
863 // Standard fields are still present
864 assert.Contains(t, out, "Fix login page")
865 assert.Contains(t, out, "OWNER/REPO#456")
866 assert.Contains(t, out, "Open")
867 assert.Contains(t, out, "The login page is broken.")
868 assert.Contains(t, out, "View this issue on GitHub: https://github.com/OWNER/REPO/issues/456")
869
870 // Issues 2.0 sections must NOT appear
871 assert.NotContains(t, out, "Type:")
872 assert.NotContains(t, out, "Parent:")
873 assert.NotContains(t, out, "Blocked by:")
874 assert.NotContains(t, out, "Blocking:")
875 assert.NotContains(t, out, "Sub-issues")
876}
877
878func TestIssueView_nontty_Issues2NoFields(t *testing.T) {
879 ios, _, stdout, stderr := iostreams.Test()

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