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

Function TestExecuteCodeBlock_ValidCodeBlockExecution

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

Source from the content-addressed store, hash-verified

134}
135
136func TestExecuteCodeBlock_ValidCodeBlockExecution(t *testing.T) {
137 launchers = map[string]LauncherBlock{"sh": {"sh", "sh"}, "bash": {"sh", "sh"}, "env": {"/usr/bin/env", "env"}}
138 codeBlock := CodeBlock{
139 Lang: "sh",
140 Code: `echo "Hello, {{.arg1}}"`,
141 Config: ConfigBlock{SheBang: false},
142 }
143 args := []string{"World"}
144 var wantErr error = nil
145
146 output, err := captureOutput(func() error {
147 return executeCodeBlock(&codeBlock, args...)
148 }, false)
149
150 expectedOutput := "Hello, World\n"
151 if output != expectedOutput {
152 t.Errorf("executeCodeBlock() output = %v, expectedOutput %v", output, expectedOutput)
153 }
154
155 if wantErr != nil {
156 if !errors.Is(err, wantErr) {
157 t.Errorf("executeCodeBlock() error = %v, wantErr %v", err, wantErr)
158 }
159 } else if err != nil {
160 t.Errorf("executeCodeBlock() error = %v, wantErr %v", err, wantErr)
161 }
162}
163
164func TestExecuteCodeBlock_ValidCodeBlockExecution_CWD(t *testing.T) {
165 launchers = map[string]LauncherBlock{"sh": {"sh", "sh"}, "bash": {"sh", "sh"}, "env": {"/usr/bin/env", "env"}}

Callers

nothing calls this directly

Calls 2

captureOutputFunction · 0.85
executeCodeBlockFunction · 0.85

Tested by

no test coverage detected