MCPcopy Create free account
hub / github.com/apache/openwhisk-cli / TestRejectCommInvalidArgs

Function TestRejectCommInvalidArgs

tests/src/integration/integration_test.go:433–451  ·  view source on GitHub ↗

Test case to reject commands that are executed with invalid arguments.

(t *testing.T)

Source from the content-addressed store, hash-verified

431
432// Test case to reject commands that are executed with invalid arguments.
433func TestRejectCommInvalidArgs(t *testing.T) {
434 initInvalidArgs()
435 for _, invalidArg := range invalidArgs {
436 cs := invalidArg.Cmd
437 cs = append(cs, "--apihost", wsk.Wskprops.APIHost)
438 stdout, err := wsk.RunCommand(cs...)
439 outputString := string(stdout)
440 assert.NotEqual(t, nil, err, "The command should fail to run.")
441 if err.Error() == "exit status 1" {
442 assert.Equal(t, "exit status 1", err.Error(), "The error should be exit status 1 or 2.")
443 } else {
444 assert.Equal(t, "exit status 2", err.Error(), "The error should be exit status 1 or 2.")
445 }
446 assert.Contains(t, outputString, invalidArg.Err,
447 "The output of the command does not contain "+invalidArg.Err)
448 assert.Contains(t, outputString, "Run 'wsk --help' for usage",
449 "The output of the command does not contain \"Run 'wsk --help' for usage\".")
450 }
451}
452
453// Test case to reject commands that are executed with invalid JSON for annotations and parameters.
454func TestRejectCommInvalidJSON(t *testing.T) {

Callers

nothing calls this directly

Calls 2

initInvalidArgsFunction · 0.85
RunCommandMethod · 0.80

Tested by

no test coverage detected