(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func TestExecuteCodeBlock_ValidCodeBlockExecution_CWD(t *testing.T) { |
| 165 | launchers = map[string]LauncherBlock{"sh": {"sh", "sh"}, "bash": {"sh", "sh"}, "env": {"/usr/bin/env", "env"}} |
| 166 | codeBlock := CodeBlock{ |
| 167 | Lang: "sh", |
| 168 | Code: `echo "Hello, {{.arg1}}" > file.txt && cat ${PWD}/file.txt && rm file.txt`, |
| 169 | Config: ConfigBlock{SheBang: false}, |
| 170 | } |
| 171 | args := []string{"World"} |
| 172 | var wantErr error = nil |
| 173 | |
| 174 | output, err := captureOutput(func() error { |
| 175 | return executeCodeBlock(&codeBlock, args...) |
| 176 | }, false) |
| 177 | |
| 178 | expectedOutput := "Hello, World\n" |
| 179 | if output != expectedOutput { |
| 180 | t.Errorf("executeCodeBlock() output = %v, expectedOutput %v", output, expectedOutput) |
| 181 | } |
| 182 | |
| 183 | if wantErr != nil { |
| 184 | if !errors.Is(err, wantErr) { |
| 185 | t.Errorf("executeCodeBlock() error = %v, wantErr %v", err, wantErr) |
| 186 | } |
| 187 | } else if err != nil { |
| 188 | t.Errorf("executeCodeBlock() error = %v, wantErr %v", err, wantErr) |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | func TestExecuteCodeBlock_ValidCodeBlockExecution_SheBang(t *testing.T) { |
| 193 | launchers = map[string]LauncherBlock{"sh": {"sh", "sh"}, "bash": {"sh", "sh"}, "env": {"/usr/bin/env", "env"}} |
nothing calls this directly
no test coverage detected