(t *testing.T)
| 662 | } |
| 663 | |
| 664 | func TestRawArgsHelpOutputFormatError(t *testing.T) { |
| 665 | tests := []struct { |
| 666 | name string |
| 667 | args []string |
| 668 | wantErr bool |
| 669 | }{ |
| 670 | { |
| 671 | name: "text help", |
| 672 | args: []string{"put", "--help"}, |
| 673 | }, |
| 674 | { |
| 675 | name: "json help", |
| 676 | args: []string{"put", "--help", "--output=json"}, |
| 677 | }, |
| 678 | { |
| 679 | name: "explicit text help", |
| 680 | args: []string{"put", "--help", "--output", "text"}, |
| 681 | }, |
| 682 | { |
| 683 | name: "invalid help output", |
| 684 | args: []string{"put", "--help", "--output=yaml"}, |
| 685 | wantErr: true, |
| 686 | }, |
| 687 | { |
| 688 | name: "invalid root help output", |
| 689 | args: []string{"--help", "--output", "yaml"}, |
| 690 | wantErr: true, |
| 691 | }, |
| 692 | { |
| 693 | name: "normal command invalid output is not help", |
| 694 | args: []string{"put", "--output=yaml", "file.txt"}, |
| 695 | }, |
| 696 | { |
| 697 | name: "last valid output wins", |
| 698 | args: []string{"put", "--output=yaml", "--output=json", "--help"}, |
| 699 | }, |
| 700 | { |
| 701 | name: "last invalid output wins", |
| 702 | args: []string{"put", "--output=json", "--output=yaml", "--help"}, |
| 703 | wantErr: true, |
| 704 | }, |
| 705 | { |
| 706 | name: "output after double dash ignored", |
| 707 | args: []string{"put", "--help", "--", "--output=yaml"}, |
| 708 | }, |
| 709 | } |
| 710 | |
| 711 | for _, tt := range tests { |
| 712 | t.Run(tt.name, func(t *testing.T) { |
| 713 | err := rawArgsHelpOutputFormatError(tt.args) |
| 714 | if tt.wantErr { |
| 715 | if err == nil { |
| 716 | t.Fatalf("rawArgsHelpOutputFormatError(%v) = nil, want error", tt.args) |
| 717 | } |
| 718 | if !strings.Contains(err.Error(), `unsupported output format "yaml"`) { |
| 719 | t.Fatalf("error = %q, want unsupported output format", err.Error()) |
| 720 | } |
| 721 | return |
nothing calls this directly
no test coverage detected