TestEngineCommandField tests that the command field is correctly extracted
(t *testing.T)
| 215 | |
| 216 | // TestEngineCommandField tests that the command field is correctly extracted |
| 217 | func TestEngineCommandField(t *testing.T) { |
| 218 | tests := []struct { |
| 219 | name string |
| 220 | frontmatter map[string]any |
| 221 | expectedCommand string |
| 222 | }{ |
| 223 | { |
| 224 | name: "command field provided", |
| 225 | frontmatter: map[string]any{ |
| 226 | "engine": map[string]any{ |
| 227 | "id": "copilot", |
| 228 | "command": "/usr/local/bin/custom-copilot", |
| 229 | }, |
| 230 | }, |
| 231 | expectedCommand: "/usr/local/bin/custom-copilot", |
| 232 | }, |
| 233 | { |
| 234 | name: "command field not provided", |
| 235 | frontmatter: map[string]any{ |
| 236 | "engine": map[string]any{ |
| 237 | "id": "copilot", |
| 238 | }, |
| 239 | }, |
| 240 | expectedCommand: "", |
| 241 | }, |
| 242 | { |
| 243 | name: "command with relative path", |
| 244 | frontmatter: map[string]any{ |
| 245 | "engine": map[string]any{ |
| 246 | "id": "claude", |
| 247 | "command": "./bin/claude-cli", |
| 248 | }, |
| 249 | }, |
| 250 | expectedCommand: "./bin/claude-cli", |
| 251 | }, |
| 252 | { |
| 253 | name: "command with environment variable", |
| 254 | frontmatter: map[string]any{ |
| 255 | "engine": map[string]any{ |
| 256 | "id": "codex", |
| 257 | "command": "$HOME/.local/bin/codex", |
| 258 | }, |
| 259 | }, |
| 260 | expectedCommand: "$HOME/.local/bin/codex", |
| 261 | }, |
| 262 | } |
| 263 | |
| 264 | compiler := NewCompiler() |
| 265 | |
| 266 | for _, tt := range tests { |
| 267 | t.Run(tt.name, func(t *testing.T) { |
| 268 | _, config := compiler.ExtractEngineConfig(tt.frontmatter) |
| 269 | |
| 270 | if config == nil { |
| 271 | t.Fatal("Expected config to be non-nil") |
| 272 | } |
| 273 | |
| 274 | if config.Command != tt.expectedCommand { |
nothing calls this directly
no test coverage detected