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

Function TestExecuteWithStepTimeout

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

Source from the content-addressed store, hash-verified

736}
737
738func TestExecuteWithStepTimeout(t *testing.T) {
739 // Create a tool that takes longer than the timeout
740 tool1 := newDelayedMockTool("tool1", "result1", 200*time.Millisecond)
741
742 toolMap := map[string]tools.Tool{
743 "tool1": tool1,
744 }
745
746 executor := NewExecutor(toolMap)
747
748 plan := NewExecutionPlan("Step timeout test")
749 plan.AddStep("tool1", "Step 1", nil)
750 plan.Options.RequireApproval = false
751 plan.Options.StepTimeoutMs = 50 // 50ms timeout
752
753 ctx := context.Background()
754 toolCtx := &tools.ToolContext{AgentID: "test-agent"}
755
756 err := executor.Execute(ctx, plan, toolCtx)
757 if err == nil {
758 t.Fatal("expected timeout error")
759 }
760
761 if plan.Steps[0].Status != StepStatusFailed {
762 t.Errorf("expected step status %v, got %v", StepStatusFailed, plan.Steps[0].Status)
763 }
764}
765
766func TestDependencyNotSatisfied(t *testing.T) {
767 tool1 := newMockTool("tool1", nil, errors.New("tool1 error"))

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected