MCPcopy Create free account
hub / github.com/dim0x69/mdx / TestExecuteCodeBlock_ValidCodeBlockExecution_SheBang

Function TestExecuteCodeBlock_ValidCodeBlockExecution_SheBang

exec_test.go:192–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

190}
191
192func 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
220func TestExecuteCodeBlock_MissingArgument(t *testing.T) {
221 codeBlock := CodeBlock{

Callers

nothing calls this directly

Calls 2

captureOutputFunction · 0.85
executeCodeBlockFunction · 0.85

Tested by

no test coverage detected