TestRepoMemoryConfigArray tests repo-memory configuration with array notation
(t *testing.T)
| 107 | |
| 108 | // TestRepoMemoryConfigArray tests repo-memory configuration with array notation |
| 109 | func TestRepoMemoryConfigArray(t *testing.T) { |
| 110 | toolsMap := map[string]any{ |
| 111 | "repo-memory": []any{ |
| 112 | map[string]any{ |
| 113 | "id": "session", |
| 114 | "branch-name": "memory/session", |
| 115 | }, |
| 116 | map[string]any{ |
| 117 | "id": "logs", |
| 118 | "branch-name": "memory/logs", |
| 119 | "max-file-size": 2097152, |
| 120 | }, |
| 121 | }, |
| 122 | } |
| 123 | |
| 124 | toolsConfig, err := ParseToolsConfig(toolsMap) |
| 125 | if err != nil { |
| 126 | t.Fatalf("Failed to parse tools config: %v", err) |
| 127 | } |
| 128 | |
| 129 | compiler := NewCompiler() |
| 130 | config, err := compiler.extractRepoMemoryConfig(toolsConfig, "") |
| 131 | if err != nil { |
| 132 | t.Fatalf("Failed to extract repo-memory config: %v", err) |
| 133 | } |
| 134 | |
| 135 | if config == nil { |
| 136 | t.Fatal("Expected non-nil config") |
| 137 | } |
| 138 | |
| 139 | if len(config.Memories) != 2 { |
| 140 | t.Fatalf("Expected 2 memories, got %d", len(config.Memories)) |
| 141 | } |
| 142 | |
| 143 | // Check first memory |
| 144 | memory1 := config.Memories[0] |
| 145 | if memory1.ID != "session" { |
| 146 | t.Errorf("Expected ID 'session', got '%s'", memory1.ID) |
| 147 | } |
| 148 | if memory1.BranchName != "memory/session" { |
| 149 | t.Errorf("Expected branch name 'memory/session', got '%s'", memory1.BranchName) |
| 150 | } |
| 151 | |
| 152 | // Check second memory |
| 153 | memory2 := config.Memories[1] |
| 154 | if memory2.ID != "logs" { |
| 155 | t.Errorf("Expected ID 'logs', got '%s'", memory2.ID) |
| 156 | } |
| 157 | if memory2.BranchName != "memory/logs" { |
| 158 | t.Errorf("Expected branch name 'memory/logs', got '%s'", memory2.BranchName) |
| 159 | } |
| 160 | if memory2.MaxFileSize != 2097152 { |
| 161 | t.Errorf("Expected max file size 2097152, got %d", memory2.MaxFileSize) |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | // TestRepoMemoryConfigDuplicateIDs tests that duplicate memory IDs are rejected |
| 166 | func TestRepoMemoryConfigDuplicateIDs(t *testing.T) { |
nothing calls this directly
no test coverage detected