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

Function TestNodeJSRuntime_Execute

pkg/tools/bridge/runtime_test.go:79–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func TestNodeJSRuntime_Execute(t *testing.T) {
80 runtime := NewNodeJSRuntime(nil)
81
82 if !runtime.IsAvailable() {
83 t.Skip("Node.js not available")
84 }
85
86 ctx := context.Background()
87 code := `
88const result = _input.a + _input.b;
89console.log(result);
90`
91 input := map[string]any{
92 "a": 10,
93 "b": 20,
94 }
95
96 result, err := runtime.Execute(ctx, code, input)
97 if err != nil {
98 t.Fatalf("Execute failed: %v", err)
99 }
100
101 if !result.Success {
102 t.Errorf("expected success, got error: %s", result.Error)
103 }
104
105 if result.Output != "30" {
106 t.Errorf("expected output '30', got %v", result.Output)
107 }
108}
109
110func TestBashRuntime_Execute(t *testing.T) {
111 runtime := NewBashRuntime(nil)

Callers

nothing calls this directly

Calls 3

IsAvailableMethod · 0.95
ExecuteMethod · 0.95
NewNodeJSRuntimeFunction · 0.85

Tested by

no test coverage detected