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

Function TestExecuteCodeBlock_ValidCodeBlockExecution_CWD

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

Source from the content-addressed store, hash-verified

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"}}
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
192func TestExecuteCodeBlock_ValidCodeBlockExecution_SheBang(t *testing.T) {
193 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