(t *testing.T)
| 624 | } |
| 625 | |
| 626 | func 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( |
nothing calls this directly
no test coverage detected