(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestCreateErrors(t *testing.T) { |
| 17 | noSuchFile := "no such file or directory" |
| 18 | if runtime.GOOS == "windows" { |
| 19 | noSuchFile = "The system cannot find the file specified." |
| 20 | } |
| 21 | testCases := []struct { |
| 22 | args []string |
| 23 | expectedError string |
| 24 | }{ |
| 25 | { |
| 26 | args: []string{}, |
| 27 | expectedError: "requires at least 2 arguments", |
| 28 | }, |
| 29 | { |
| 30 | args: []string{"INVALID_TAG", "context-dir"}, |
| 31 | expectedError: "invalid", |
| 32 | }, |
| 33 | { |
| 34 | args: []string{"plugin-foo", "nonexistent_context_dir"}, |
| 35 | expectedError: noSuchFile, |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | for _, tc := range testCases { |
| 40 | cli := test.NewFakeCli(&fakeClient{}) |
| 41 | cmd := newCreateCommand(cli) |
| 42 | cmd.SetArgs(tc.args) |
| 43 | cmd.SetOut(io.Discard) |
| 44 | cmd.SetErr(io.Discard) |
| 45 | assert.ErrorContains(t, cmd.Execute(), tc.expectedError) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | func TestCreateErrorOnFileAsContextDir(t *testing.T) { |
| 50 | tmpFile := fs.NewFile(t, "file-as-context-dir") |
nothing calls this directly
no test coverage detected
searching dependent graphs…