MCPcopy
hub / github.com/cli/cli / TestIssueView_tty_Issues2AllFields

Function TestIssueView_tty_Issues2AllFields

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

Source from the content-addressed store, hash-verified

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