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

Function TestIssueView_tty_Issues2NoFields

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

Source from the content-addressed store, hash-verified

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