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

Function TestExecuteWithDependencies

pkg/executionplan/executor_test.go:327–361  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

325}
326
327func TestExecuteWithDependencies(t *testing.T) {
328 tool1 := newMockTool("tool1", "result1", nil)
329 tool2 := newMockTool("tool2", "result2", nil)
330 tool3 := newMockTool("tool3", "result3", nil)
331
332 toolMap := map[string]tools.Tool{
333 "tool1": tool1,
334 "tool2": tool2,
335 "tool3": tool3,
336 }
337
338 executor := NewExecutor(toolMap)
339
340 plan := NewExecutionPlan("Dependencies test")
341 step1 := plan.AddStep("tool1", "Step 1", nil)
342 step2 := plan.AddStep("tool2", "Step 2", nil)
343 step2.DependsOn = []string{step1.ID}
344 step3 := plan.AddStep("tool3", "Step 3", nil)
345 step3.DependsOn = []string{step2.ID}
346 plan.Options.RequireApproval = false
347
348 ctx := context.Background()
349 toolCtx := &tools.ToolContext{AgentID: "test-agent"}
350
351 err := executor.Execute(ctx, plan, toolCtx)
352 if err != nil {
353 t.Fatalf("unexpected error: %v", err)
354 }
355
356 for i, step := range plan.Steps {
357 if step.Status != StepStatusCompleted {
358 t.Errorf("step %d: expected %v, got %v", i, StepStatusCompleted, step.Status)
359 }
360 }
361}
362
363func TestExecuteParallelWithDependencies(t *testing.T) {
364 tool1 := newDelayedMockTool("install", "installed", 30*time.Millisecond)

Callers

nothing calls this directly

Calls 5

AddStepMethod · 0.95
ExecuteMethod · 0.95
newMockToolFunction · 0.85
NewExecutionPlanFunction · 0.85
NewExecutorFunction · 0.70

Tested by

no test coverage detected