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

Function TestGetStep

pkg/executionplan/types_test.go:93–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

91}
92
93func TestGetStep(t *testing.T) {
94 plan := NewExecutionPlan("Test plan")
95 plan.AddStep("tool1", "Step 1", nil)
96 plan.AddStep("tool2", "Step 2", nil)
97 plan.AddStep("tool3", "Step 3", nil)
98
99 tests := []struct {
100 name string
101 index int
102 expected string
103 isNil bool
104 }{
105 {"first step", 0, "tool1", false},
106 {"second step", 1, "tool2", false},
107 {"third step", 2, "tool3", false},
108 {"negative index", -1, "", true},
109 {"out of bounds", 10, "", true},
110 }
111
112 for _, tt := range tests {
113 t.Run(tt.name, func(t *testing.T) {
114 step := plan.GetStep(tt.index)
115 if tt.isNil {
116 if step != nil {
117 t.Errorf("expected nil, got %v", step)
118 }
119 } else {
120 if step == nil {
121 t.Fatal("expected non-nil step")
122 }
123 if step.ToolName != tt.expected {
124 t.Errorf("expected tool %q, got %q", tt.expected, step.ToolName)
125 }
126 }
127 })
128 }
129}
130
131func TestGetCurrentStep(t *testing.T) {
132 plan := NewExecutionPlan("Test plan")

Callers

nothing calls this directly

Calls 4

AddStepMethod · 0.95
GetStepMethod · 0.95
NewExecutionPlanFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected