this test forces the cat implementation to execute
(t *testing.T)
| 75 | |
| 76 | // this test forces the cat implementation to execute |
| 77 | func TestShellCatEnforce(t *testing.T) { |
| 78 | file, err := os.CreateTemp(".", "testFile") |
| 79 | if err != nil { |
| 80 | t.Fatal(err) |
| 81 | } |
| 82 | defer os.Remove(file.Name()) |
| 83 | |
| 84 | if _, err = file.WriteString("Hello DevSpace!"); err != nil { |
| 85 | t.Fatalf("Unable to write to temporary file %v", err) |
| 86 | } |
| 87 | |
| 88 | testCases := []testCaseShell{ |
| 89 | { |
| 90 | command: "cat " + filepath.ToSlash(file.Name()), |
| 91 | expectedOutput: "Hello DevSpace!", |
| 92 | }, |
| 93 | { |
| 94 | command: "echo 123 | cat", |
| 95 | expectedOutput: "123\n", |
| 96 | }, |
| 97 | } |
| 98 | |
| 99 | for _, testCase := range testCases { |
| 100 | stdout := &bytes.Buffer{} |
| 101 | err := ExecuteSimpleShellCommand(context.Background(), ".", expand.ListEnviron(os.Environ()...), stdout, nil, nil, testCase.command) |
| 102 | if err != nil { |
| 103 | t.Fatal(err) |
| 104 | } |
| 105 | assert.Equal(t, stdout.String(), testCase.expectedOutput) |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | func TestKubectlDownload(t *testing.T) { |
| 110 | stdout := &bytes.Buffer{} |
nothing calls this directly
no test coverage detected