(t *testing.T)
| 3820 | } |
| 3821 | |
| 3822 | func TestDisableDescriptions(t *testing.T) { |
| 3823 | rootCmd := &Command{ |
| 3824 | Use: "root", |
| 3825 | Run: emptyRun, |
| 3826 | } |
| 3827 | |
| 3828 | childCmd := &Command{ |
| 3829 | Use: "thechild", |
| 3830 | Short: "The child command", |
| 3831 | Run: emptyRun, |
| 3832 | } |
| 3833 | rootCmd.AddCommand(childCmd) |
| 3834 | |
| 3835 | specificDescriptionsEnvVar := configEnvVar(rootCmd.Name(), configEnvVarSuffixDescriptions) |
| 3836 | globalDescriptionsEnvVar := configEnvVar(configEnvVarGlobalPrefix, configEnvVarSuffixDescriptions) |
| 3837 | |
| 3838 | const ( |
| 3839 | descLineWithDescription = "first\tdescription" |
| 3840 | descLineWithoutDescription = "first" |
| 3841 | ) |
| 3842 | childCmd.ValidArgsFunction = func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective) { |
| 3843 | comps := []string{descLineWithDescription} |
| 3844 | return comps, ShellCompDirectiveDefault |
| 3845 | } |
| 3846 | |
| 3847 | testCases := []struct { |
| 3848 | desc string |
| 3849 | globalEnvValue string |
| 3850 | specificEnvValue string |
| 3851 | expectedLine string |
| 3852 | }{ |
| 3853 | { |
| 3854 | "No env variables set", |
| 3855 | "", |
| 3856 | "", |
| 3857 | descLineWithDescription, |
| 3858 | }, |
| 3859 | { |
| 3860 | "Global value false", |
| 3861 | "false", |
| 3862 | "", |
| 3863 | descLineWithoutDescription, |
| 3864 | }, |
| 3865 | { |
| 3866 | "Specific value false", |
| 3867 | "", |
| 3868 | "false", |
| 3869 | descLineWithoutDescription, |
| 3870 | }, |
| 3871 | { |
| 3872 | "Both values false", |
| 3873 | "false", |
| 3874 | "false", |
| 3875 | descLineWithoutDescription, |
| 3876 | }, |
| 3877 | { |
| 3878 | "Both values true", |
| 3879 | "true", |
nothing calls this directly
no test coverage detected