MCPcopy Create free account
hub / github.com/astercloud/aster / TestLocalSandbox_Exec

Function TestLocalSandbox_Exec

pkg/sandbox/local_test.go:37–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestLocalSandbox_Exec(t *testing.T) {
38 tmpDir, err := os.MkdirTemp("", "sandbox-test-*")
39 if err != nil {
40 t.Fatalf("failed to create temp dir: %v", err)
41 }
42 defer func() { _ = os.RemoveAll(tmpDir) }()
43
44 sb, err := NewLocalSandbox(&LocalSandboxConfig{
45 WorkDir: tmpDir,
46 })
47 if err != nil {
48 t.Fatalf("failed to create sandbox: %v", err)
49 }
50 defer func() { _ = sb.Dispose() }()
51
52 ctx := context.Background()
53
54 // Test simple command
55 result, err := sb.Exec(ctx, "echo hello", nil)
56 if err != nil {
57 t.Fatalf("exec failed: %v", err)
58 }
59 if result.Code != 0 {
60 t.Errorf("expected exit code 0, got %d", result.Code)
61 }
62 if result.Stdout != "hello\n" {
63 t.Errorf("expected stdout='hello\\n', got '%s'", result.Stdout)
64 }
65}
66
67func TestLocalSandbox_DangerousCommand(t *testing.T) {
68 tmpDir, err := os.MkdirTemp("", "sandbox-test-*")

Callers

nothing calls this directly

Calls 3

DisposeMethod · 0.95
ExecMethod · 0.95
NewLocalSandboxFunction · 0.85

Tested by

no test coverage detected