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

Function TestExecuteRequiresApproval

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

Source from the content-addressed store, hash-verified

411}
412
413func TestExecuteRequiresApproval(t *testing.T) {
414 toolMap := map[string]tools.Tool{
415 "tool1": newMockTool("tool1", "result1", nil),
416 }
417
418 executor := NewExecutor(toolMap)
419
420 plan := NewExecutionPlan("Requires approval")
421 plan.AddStep("tool1", "Step 1", nil)
422 plan.Options.RequireApproval = true
423
424 ctx := context.Background()
425 toolCtx := &tools.ToolContext{AgentID: "test-agent"}
426
427 err := executor.Execute(ctx, plan, toolCtx)
428 if err == nil {
429 t.Fatal("expected error for unapproved plan")
430 }
431
432 if plan.Status != StatusDraft {
433 t.Errorf("expected status %v, got %v", StatusDraft, plan.Status)
434 }
435
436 // Now approve and execute
437 plan.Approve("test-user")
438 err = executor.Execute(ctx, plan, toolCtx)
439 if err != nil {
440 t.Fatalf("unexpected error after approval: %v", err)
441 }
442
443 if plan.Status != StatusCompleted {
444 t.Errorf("expected status %v, got %v", StatusCompleted, plan.Status)
445 }
446}
447
448func TestExecuteContextCancellation(t *testing.T) {
449 tool1 := newDelayedMockTool("tool1", "result1", 100*time.Millisecond)

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected