(t *testing.T)
| 2082 | } |
| 2083 | |
| 2084 | func TestPrintHelpCustomTemplateError(t *testing.T) { |
| 2085 | tmpls := []*string{ |
| 2086 | &helpNameTemplate, |
| 2087 | &argsTemplate, |
| 2088 | &usageTemplate, |
| 2089 | &descriptionTemplate, |
| 2090 | &visibleCommandTemplate, |
| 2091 | ©rightTemplate, |
| 2092 | &versionTemplate, |
| 2093 | &visibleFlagCategoryTemplate, |
| 2094 | &visibleFlagTemplate, |
| 2095 | &visiblePersistentFlagTemplate, |
| 2096 | &visibleFlagCategoryTemplate, |
| 2097 | &authorsTemplate, |
| 2098 | &visibleCommandCategoryTemplate, |
| 2099 | } |
| 2100 | |
| 2101 | oldErrWriter := ErrWriter |
| 2102 | defer func() { ErrWriter = oldErrWriter }() |
| 2103 | |
| 2104 | t.Setenv("CLI_TEMPLATE_ERROR_DEBUG", "true") |
| 2105 | |
| 2106 | for _, tmpl := range tmpls { |
| 2107 | oldtmpl := *tmpl |
| 2108 | // safety mechanism in case something fails |
| 2109 | defer func(stmpl *string) { *stmpl = oldtmpl }(tmpl) |
| 2110 | |
| 2111 | errBuf := &bytes.Buffer{} |
| 2112 | ErrWriter = errBuf |
| 2113 | buf := &bytes.Buffer{} |
| 2114 | |
| 2115 | *tmpl = "{{junk" |
| 2116 | DefaultPrintHelpCustom(buf, "", "", nil) |
| 2117 | |
| 2118 | assert.Contains(t, errBuf.String(), "CLI TEMPLATE ERROR") |
| 2119 | |
| 2120 | // reset template back. |
| 2121 | *tmpl = oldtmpl |
| 2122 | } |
| 2123 | } |
| 2124 | |
| 2125 | func TestCustomUsageCommandHelp(t *testing.T) { |
| 2126 | old := UsageCommandHelp |
nothing calls this directly
no test coverage detected