(t *testing.T)
| 241 | } |
| 242 | |
| 243 | func Test_Version_Custom_Flags(t *testing.T) { |
| 244 | oldFlag := VersionFlag |
| 245 | defer func() { |
| 246 | VersionFlag = oldFlag |
| 247 | }() |
| 248 | |
| 249 | VersionFlag = &BoolFlag{ |
| 250 | Name: "version", |
| 251 | Aliases: []string{"V"}, |
| 252 | Usage: "show version", |
| 253 | } |
| 254 | |
| 255 | out := &bytes.Buffer{} |
| 256 | cmd := &Command{ |
| 257 | Flags: []Flag{ |
| 258 | &BoolFlag{Name: "foo", Aliases: []string{"v"}}, |
| 259 | }, |
| 260 | Action: func(_ context.Context, cmd *Command) error { |
| 261 | assert.True(t, cmd.Bool("v"), "custom version flag not set") |
| 262 | return nil |
| 263 | }, |
| 264 | Writer: out, |
| 265 | } |
| 266 | |
| 267 | _ = cmd.Run(buildTestContext(t), []string{"test", "-v"}) |
| 268 | require.Len(t, out.String(), 0) |
| 269 | } |
| 270 | |
| 271 | func Test_helpCommand_Action_ErrorIfNoTopic(t *testing.T) { |
| 272 | cmd := &Command{} |
nothing calls this directly
no test coverage detected