TestRepoMemoryMaxFileCountValidationArray tests max-file-count validation in array notation
(t *testing.T)
| 601 | |
| 602 | // TestRepoMemoryMaxFileCountValidationArray tests max-file-count validation in array notation |
| 603 | func TestRepoMemoryMaxFileCountValidationArray(t *testing.T) { |
| 604 | tests := []struct { |
| 605 | name string |
| 606 | maxFileCount int |
| 607 | wantError bool |
| 608 | errorText string |
| 609 | }{ |
| 610 | { |
| 611 | name: "valid count in array", |
| 612 | maxFileCount: 50, |
| 613 | wantError: false, |
| 614 | }, |
| 615 | { |
| 616 | name: "invalid count in array (zero)", |
| 617 | maxFileCount: 0, |
| 618 | wantError: true, |
| 619 | errorText: "max-file-count must be between 1 and 1000, got 0", |
| 620 | }, |
| 621 | { |
| 622 | name: "invalid count in array (exceeds max)", |
| 623 | maxFileCount: 1001, |
| 624 | wantError: true, |
| 625 | errorText: "max-file-count must be between 1 and 1000, got 1001", |
| 626 | }, |
| 627 | } |
| 628 | |
| 629 | for _, tt := range tests { |
| 630 | t.Run(tt.name, func(t *testing.T) { |
| 631 | toolsMap := map[string]any{ |
| 632 | "repo-memory": []any{ |
| 633 | map[string]any{ |
| 634 | "id": "test", |
| 635 | "max-file-count": tt.maxFileCount, |
| 636 | }, |
| 637 | }, |
| 638 | } |
| 639 | |
| 640 | toolsConfig, err := ParseToolsConfig(toolsMap) |
| 641 | if err != nil { |
| 642 | t.Fatalf("Failed to parse tools config: %v", err) |
| 643 | } |
| 644 | |
| 645 | compiler := NewCompiler() |
| 646 | config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") |
| 647 | |
| 648 | if tt.wantError { |
| 649 | if err == nil { |
| 650 | t.Errorf("Expected error, got nil") |
| 651 | } else if !strings.Contains(err.Error(), tt.errorText) { |
| 652 | t.Errorf("Expected error containing '%s', got '%s'", tt.errorText, err.Error()) |
| 653 | } |
| 654 | } else { |
| 655 | if err != nil { |
| 656 | t.Errorf("Expected no error, got: %v", err) |
| 657 | } |
| 658 | if config == nil { |
| 659 | t.Fatal("Expected non-nil config") |
| 660 | } |
nothing calls this directly
no test coverage detected