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

Function TestResume

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

Source from the content-addressed store, hash-verified

541}
542
543func TestResume(t *testing.T) {
544 tool1 := newMockTool("tool1", "result1", nil)
545 tool2 := newMockTool("tool2", "result2", nil)
546
547 toolMap := map[string]tools.Tool{
548 "tool1": tool1,
549 "tool2": tool2,
550 }
551
552 executor := NewExecutor(toolMap)
553
554 plan := NewExecutionPlan("Resume test")
555 plan.AddStep("tool1", "Step 1", nil)
556 plan.AddStep("tool2", "Step 2", nil)
557 plan.Options.RequireApproval = false
558
559 // Simulate partial execution
560 plan.Steps[0].Status = StepStatusCompleted
561
562 ctx := context.Background()
563 toolCtx := &tools.ToolContext{AgentID: "test-agent"}
564
565 err := executor.Resume(ctx, plan, toolCtx)
566 if err != nil {
567 t.Fatalf("unexpected error: %v", err)
568 }
569
570 if plan.Status != StatusCompleted {
571 t.Errorf("expected status %v, got %v", StatusCompleted, plan.Status)
572 }
573
574 // tool1 should not have been executed again
575 if tool1.ExecutionCount() != 0 {
576 t.Errorf("tool1 was executed %d times, expected 0", tool1.ExecutionCount())
577 }
578
579 // tool2 should have been executed
580 if tool2.ExecutionCount() != 1 {
581 t.Errorf("tool2 was executed %d times, expected 1", tool2.ExecutionCount())
582 }
583}
584
585func TestResumeFromFailed(t *testing.T) {
586 tool1 := &mockTool{

Callers

nothing calls this directly

Calls 6

AddStepMethod · 0.95
ResumeMethod · 0.95
newMockToolFunction · 0.85
NewExecutionPlanFunction · 0.85
ExecutionCountMethod · 0.80
NewExecutorFunction · 0.70

Tested by

no test coverage detected