TestUnknownCommand tests https://github.com/containerd/nerdctl/issues/487
(t *testing.T)
| 35 | |
| 36 | // TestUnknownCommand tests https://github.com/containerd/nerdctl/issues/487 |
| 37 | func TestUnknownCommand(t *testing.T) { |
| 38 | testCase := nerdtest.Setup() |
| 39 | |
| 40 | var cmd = errors.New("unknown subcommand") |
| 41 | |
| 42 | testCase.SubTests = []*test.Case{ |
| 43 | { |
| 44 | Description: "non-existent-command", |
| 45 | Command: test.Command("non-existent-command"), |
| 46 | Expected: test.Expects(1, []error{cmd}, nil), |
| 47 | }, |
| 48 | { |
| 49 | Description: "non-existent-command info", |
| 50 | Command: test.Command("non-existent-command", "info"), |
| 51 | Expected: test.Expects(1, []error{cmd}, nil), |
| 52 | }, |
| 53 | { |
| 54 | Description: "system non-existent-command", |
| 55 | Command: test.Command("system", "non-existent-command"), |
| 56 | Expected: test.Expects(1, []error{cmd}, nil), |
| 57 | }, |
| 58 | { |
| 59 | Description: "system non-existent-command info", |
| 60 | Command: test.Command("system", "non-existent-command", "info"), |
| 61 | Expected: test.Expects(1, []error{cmd}, nil), |
| 62 | }, |
| 63 | { |
| 64 | Description: "system", |
| 65 | Command: test.Command("system"), |
| 66 | Expected: test.Expects(0, nil, nil), |
| 67 | }, |
| 68 | { |
| 69 | Description: "system info", |
| 70 | Command: test.Command("system", "info"), |
| 71 | Expected: test.Expects(0, nil, expect.Contains("Kernel Version:")), |
| 72 | }, |
| 73 | { |
| 74 | Description: "info", |
| 75 | Command: test.Command("info"), |
| 76 | Expected: test.Expects(0, nil, expect.Contains("Kernel Version:")), |
| 77 | }, |
| 78 | } |
| 79 | |
| 80 | testCase.Run(t) |
| 81 | } |
| 82 | |
| 83 | // TestNerdctlConfig validates the configuration precedence [CLI, Env, TOML, Default] and broken config rejection |
| 84 | func TestNerdctlConfig(t *testing.T) { |