(t *testing.T)
| 220 | } |
| 221 | |
| 222 | func TestUpdateStep(t *testing.T) { |
| 223 | chain := NewChain(ChainConfig{MaxSteps: 5}) |
| 224 | |
| 225 | step := Step{ |
| 226 | Title: "Initial Title", |
| 227 | Confidence: 0.5, |
| 228 | Status: StepStatusPending, |
| 229 | } |
| 230 | |
| 231 | if err := chain.AddStep(step); err != nil { |
| 232 | t.Fatalf("AddStep failed: %v", err) |
| 233 | } |
| 234 | stepID := chain.Steps[0].ID |
| 235 | |
| 236 | // 更新步骤 |
| 237 | updates := map[string]any{ |
| 238 | "result": "Updated result", |
| 239 | "status": StepStatusCompleted, |
| 240 | "confidence": 0.9, |
| 241 | } |
| 242 | |
| 243 | err := chain.UpdateStep(stepID, updates) |
| 244 | if err != nil { |
| 245 | t.Fatalf("UpdateStep failed: %v", err) |
| 246 | } |
| 247 | |
| 248 | // 验证更新 |
| 249 | updated := chain.Steps[0] |
| 250 | if updated.Result != "Updated result" { |
| 251 | t.Errorf("expected result='Updated result', got '%s'", updated.Result) |
| 252 | } |
| 253 | if updated.Status != StepStatusCompleted { |
| 254 | t.Errorf("expected status=completed, got %s", updated.Status) |
| 255 | } |
| 256 | if updated.Confidence != 0.9 { |
| 257 | t.Errorf("expected confidence=0.9, got %f", updated.Confidence) |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | func contains(s, substr string) bool { |
| 262 | return len(s) >= len(substr) && (s == substr || len(s) > len(substr)) |
nothing calls this directly
no test coverage detected