(t *testing.T)
| 292 | } |
| 293 | |
| 294 | func TestSimplicityChecker_Reset(t *testing.T) { |
| 295 | m := NewSimplicityCheckerMiddleware(&SimplicityCheckerConfig{ |
| 296 | Enabled: true, |
| 297 | MaxHelperFunctions: 1, |
| 298 | }) |
| 299 | |
| 300 | code := `func parseHelper() {}` |
| 301 | |
| 302 | req := &ToolCallRequest{ |
| 303 | ToolName: "Write", |
| 304 | ToolInput: map[string]any{ |
| 305 | "file_path": "test.go", |
| 306 | "content": code, |
| 307 | }, |
| 308 | } |
| 309 | |
| 310 | handler := func(ctx context.Context, req *ToolCallRequest) (*ToolCallResponse, error) { |
| 311 | return &ToolCallResponse{Result: "ok"}, nil |
| 312 | } |
| 313 | |
| 314 | _, _ = m.WrapToolCall(context.Background(), req, handler) |
| 315 | |
| 316 | if m.helperCount == 0 { |
| 317 | t.Error("Expected helperCount > 0 after detection") |
| 318 | } |
| 319 | |
| 320 | // 重置 |
| 321 | m.Reset() |
| 322 | |
| 323 | if m.helperCount != 0 { |
| 324 | t.Errorf("Expected helperCount=0 after reset, got %d", m.helperCount) |
| 325 | } |
| 326 | if len(m.GetWarnings()) != 0 { |
| 327 | t.Error("Expected empty warnings after reset") |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | func TestSimplicityChecker_OnAgentStart(t *testing.T) { |
| 332 | m := NewSimplicityCheckerMiddleware(&SimplicityCheckerConfig{ |
nothing calls this directly
no test coverage detected