TestPlugin checks usage as plugin for another command such as kubectl. The executable is `kubectl-plugin`, but we run it as `kubectl plugin`. The help text should reflect the way we run the command.
(t *testing.T)
| 370 | // executable is `kubectl-plugin`, but we run it as `kubectl plugin`. The help |
| 371 | // text should reflect the way we run the command. |
| 372 | func TestPlugin(t *testing.T) { |
| 373 | cmd := &Command{ |
| 374 | Use: "kubectl-plugin", |
| 375 | Version: "1.0.0", |
| 376 | Args: NoArgs, |
| 377 | Annotations: map[string]string{ |
| 378 | CommandDisplayNameAnnotation: "kubectl plugin", |
| 379 | }, |
| 380 | Run: emptyRun, |
| 381 | } |
| 382 | |
| 383 | cmdHelp, err := executeCommand(cmd, "-h") |
| 384 | if err != nil { |
| 385 | t.Errorf("Unexpected error: %v", err) |
| 386 | } |
| 387 | |
| 388 | checkStringContains(t, cmdHelp, "kubectl plugin [flags]") |
| 389 | checkStringContains(t, cmdHelp, "help for kubectl plugin") |
| 390 | checkStringContains(t, cmdHelp, "version for kubectl plugin") |
| 391 | } |
| 392 | |
| 393 | // TestPluginWithSubCommands checks usage as plugin with sub commands. |
| 394 | func TestPluginWithSubCommands(t *testing.T) { |
nothing calls this directly
no test coverage detected