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

Function TestRuntimeManager_Execute

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

Source from the content-addressed store, hash-verified

133}
134
135func TestRuntimeManager_Execute(t *testing.T) {
136 manager := NewRuntimeManager(nil)
137
138 // 检查可用语言
139 langs := manager.AvailableLanguages()
140 if len(langs) == 0 {
141 t.Skip("No runtimes available")
142 }
143
144 ctx := context.Background()
145
146 // 测试每个可用的运行时
147 for _, lang := range langs {
148 t.Run(string(lang), func(t *testing.T) {
149 var code string
150 switch lang {
151 case LangPython:
152 code = "print('test')"
153 case LangNodeJS:
154 code = "console.log('test')"
155 case LangBash:
156 code = "echo test"
157 }
158
159 result, err := manager.Execute(ctx, lang, code, nil)
160 if err != nil {
161 t.Fatalf("Execute failed: %v", err)
162 }
163
164 if !result.Success {
165 t.Errorf("expected success, got error: %s", result.Error)
166 }
167 })
168 }
169}
170
171func TestRuntime_Timeout(t *testing.T) {
172 config := &RuntimeConfig{

Callers

nothing calls this directly

Calls 4

AvailableLanguagesMethod · 0.95
ExecuteMethod · 0.95
NewRuntimeManagerFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected