MCPcopy
hub / github.com/cli/cli / Test_ViewRun_HandlesSpecialCharacters

Function Test_ViewRun_HandlesSpecialCharacters

pkg/cmd/repo/view/view_test.go:626–707  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

624}
625
626func Test_ViewRun_HandlesSpecialCharacters(t *testing.T) {
627 tests := []struct {
628 name string
629 opts *ViewOptions
630 repoName string
631 stdoutTTY bool
632 wantOut string
633 wantStderr string
634 wantErr bool
635 }{
636 {
637 name: "nontty",
638 wantOut: heredoc.Doc(`
639 name: OWNER/REPO
640 description: Some basic special characters " & / < > '
641 --
642 # < is always > than & ' and "
643 `),
644 },
645 {
646 name: "no args",
647 stdoutTTY: true,
648 wantOut: heredoc.Doc(`
649 OWNER/REPO
650 Some basic special characters " & / < > '
651
652
653 # < is always > than & ' and "
654
655
656
657 View this repository on GitHub: https://github.com/OWNER/REPO
658 `),
659 },
660 }
661 for _, tt := range tests {
662 if tt.opts == nil {
663 tt.opts = &ViewOptions{}
664 }
665
666 if tt.repoName == "" {
667 tt.repoName = "OWNER/REPO"
668 }
669
670 tt.opts.BaseRepo = func() (ghrepo.Interface, error) {
671 repo, _ := ghrepo.FromFullName(tt.repoName)
672 return repo, nil
673 }
674
675 reg := &httpmock.Registry{}
676 reg.Register(
677 httpmock.GraphQL(`query RepositoryInfo\b`),
678 httpmock.StringResponse(`
679 { "data": {
680 "repository": {
681 "description": "Some basic special characters \" & / < > '"
682 } } }`))
683 reg.Register(

Callers

nothing calls this directly

Calls 13

RegisterMethod · 0.95
VerifyMethod · 0.95
FromFullNameFunction · 0.92
GraphQLFunction · 0.92
StringResponseFunction · 0.92
RESTFunction · 0.92
TestFunction · 0.92
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
viewRunFunction · 0.70
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected