(t *testing.T)
| 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"}} |
| 194 | codeBlock := CodeBlock{ |
| 195 | Lang: "sh", |
| 196 | Code: "#!/bin/sh" + "\n" + `echo "Hello, {{.arg1}}"`, |
| 197 | Config: ConfigBlock{SheBang: true}, |
| 198 | } |
| 199 | args := []string{"World"} |
| 200 | var wantErr error = nil |
| 201 | |
| 202 | output, err := captureOutput(func() error { |
| 203 | return executeCodeBlock(&codeBlock, args...) |
| 204 | }, false) |
| 205 | |
| 206 | expectedOutput := "Hello, World\n" |
| 207 | if output != expectedOutput { |
| 208 | t.Errorf("executeCodeBlock() output = %v, expectedOutput %v", output, expectedOutput) |
| 209 | } |
| 210 | |
| 211 | if wantErr != nil { |
| 212 | if !errors.Is(err, wantErr) { |
| 213 | t.Errorf("executeCodeBlock() error = %v, wantErr %v", err, wantErr) |
| 214 | } |
| 215 | } else if err != nil { |
| 216 | t.Errorf("executeCodeBlock() error = %v, wantErr %v", err, wantErr) |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | func TestExecuteCodeBlock_MissingArgument(t *testing.T) { |
| 221 | codeBlock := CodeBlock{ |
nothing calls this directly
no test coverage detected