(t *testing.T)
| 894 | } |
| 895 | |
| 896 | func TestOutputJSONRequested(t *testing.T) { |
| 897 | tests := []struct { |
| 898 | name string |
| 899 | args []string |
| 900 | want bool |
| 901 | }{ |
| 902 | { |
| 903 | name: "equals", |
| 904 | args: []string{"--output=json", "missing"}, |
| 905 | want: true, |
| 906 | }, |
| 907 | { |
| 908 | name: "separate", |
| 909 | args: []string{"--output", "json", "missing"}, |
| 910 | want: true, |
| 911 | }, |
| 912 | { |
| 913 | name: "text", |
| 914 | args: []string{"--output=text", "missing"}, |
| 915 | want: false, |
| 916 | }, |
| 917 | { |
| 918 | name: "invalid format", |
| 919 | args: []string{"--output", "yaml", "missing"}, |
| 920 | want: false, |
| 921 | }, |
| 922 | { |
| 923 | name: "invalid format before json", |
| 924 | args: []string{"--output", "yaml", "--output", "json", "missing"}, |
| 925 | want: true, |
| 926 | }, |
| 927 | { |
| 928 | name: "invalid format after json", |
| 929 | args: []string{"--output", "json", "--output", "yaml", "missing"}, |
| 930 | want: false, |
| 931 | }, |
| 932 | { |
| 933 | name: "last separate flag wins text", |
| 934 | args: []string{"--output", "json", "--output", "text", "missing"}, |
| 935 | want: false, |
| 936 | }, |
| 937 | { |
| 938 | name: "last separate flag wins json", |
| 939 | args: []string{"--output", "text", "--output", "json", "missing"}, |
| 940 | want: true, |
| 941 | }, |
| 942 | { |
| 943 | name: "last equals flag wins text", |
| 944 | args: []string{"--output=json", "--output=text", "missing"}, |
| 945 | want: false, |
| 946 | }, |
| 947 | { |
| 948 | name: "last equals flag wins json", |
| 949 | args: []string{"--output=text", "--output=json", "missing"}, |
| 950 | want: true, |
| 951 | }, |
| 952 | { |
| 953 | name: "after double dash", |
nothing calls this directly
no test coverage detected