(t *testing.T)
| 151 | } |
| 152 | |
| 153 | func TestEngineExtensionsFieldExtraction(t *testing.T) { |
| 154 | compiler := NewCompiler() |
| 155 | |
| 156 | t.Run("Extensions field extraction with []any", func(t *testing.T) { |
| 157 | frontmatter := map[string]any{ |
| 158 | "engine": map[string]any{ |
| 159 | "id": "pi", |
| 160 | "extensions": []any{"@pi/web-search", "@pi/file-browser"}, |
| 161 | }, |
| 162 | } |
| 163 | |
| 164 | _, config := compiler.ExtractEngineConfig(frontmatter) |
| 165 | if config == nil { |
| 166 | t.Fatal("Expected config to be non-nil") |
| 167 | } |
| 168 | if len(config.Extensions) != 2 { |
| 169 | t.Errorf("Expected 2 extensions, got %d", len(config.Extensions)) |
| 170 | } |
| 171 | if config.Extensions[0] != "@pi/web-search" || config.Extensions[1] != "@pi/file-browser" { |
| 172 | t.Errorf("Expected [@pi/web-search @pi/file-browser], got %v", config.Extensions) |
| 173 | } |
| 174 | }) |
| 175 | |
| 176 | t.Run("Extensions field extraction with []string", func(t *testing.T) { |
| 177 | frontmatter := map[string]any{ |
| 178 | "engine": map[string]any{ |
| 179 | "id": "pi", |
| 180 | "extensions": []string{"@pi/web-search", "@pi/file-browser"}, |
| 181 | }, |
| 182 | } |
| 183 | |
| 184 | _, config := compiler.ExtractEngineConfig(frontmatter) |
| 185 | if config == nil { |
| 186 | t.Fatal("Expected config to be non-nil") |
| 187 | } |
| 188 | if len(config.Extensions) != 2 { |
| 189 | t.Errorf("Expected 2 extensions, got %d", len(config.Extensions)) |
| 190 | } |
| 191 | if config.Extensions[0] != "@pi/web-search" || config.Extensions[1] != "@pi/file-browser" { |
| 192 | t.Errorf("Expected [@pi/web-search @pi/file-browser], got %v", config.Extensions) |
| 193 | } |
| 194 | }) |
| 195 | |
| 196 | t.Run("Extensions field not present", func(t *testing.T) { |
| 197 | frontmatter := map[string]any{ |
| 198 | "engine": map[string]any{ |
| 199 | "id": "pi", |
| 200 | }, |
| 201 | } |
| 202 | |
| 203 | _, config := compiler.ExtractEngineConfig(frontmatter) |
| 204 | if config == nil { |
| 205 | t.Fatal("Expected config to be non-nil") |
| 206 | } |
| 207 | if config.Extensions != nil { |
| 208 | t.Errorf("Expected Extensions to be nil, got %v", config.Extensions) |
| 209 | } |
| 210 | }) |
nothing calls this directly
no test coverage detected