(t *testing.T)
| 50 | } |
| 51 | |
| 52 | func TestShellCatError(t *testing.T) { |
| 53 | testCases := []testCaseShell{ |
| 54 | { |
| 55 | command: "cat noFile.txt", |
| 56 | expectedOutput: "cat: noFile.txt: No such file or directory\n", |
| 57 | }, |
| 58 | } |
| 59 | |
| 60 | for _, testCase := range testCases { |
| 61 | stderr := &bytes.Buffer{} |
| 62 | err := ExecuteSimpleShellCommand(context.Background(), ".", expand.ListEnviron(os.Environ()...), stderr, stderr, nil, testCase.command) |
| 63 | if err != nil { |
| 64 | if stderr.String() != "" { |
| 65 | assert.Equal(t, stderr.String(), testCase.expectedOutput) |
| 66 | } else { |
| 67 | t.Fatal(err) |
| 68 | } |
| 69 | } else { |
| 70 | t.Fatal("FAIL: TestShellCatError") |
| 71 | } |
| 72 | |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | // this test forces the cat implementation to execute |
| 77 | func TestShellCatEnforce(t *testing.T) { |
nothing calls this directly
no test coverage detected