(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestEngineRegistry(t *testing.T) { |
| 14 | t.Run("built-in engines are registered", func(t *testing.T) { |
| 15 | registry := NewEngineRegistry() |
| 16 | supportedEngines := registry.GetSupportedEngines() |
| 17 | |
| 18 | expectedEngineIDs := []string{"claude", "codex", "copilot", "gemini", "opencode", "crush"} |
| 19 | for _, engineID := range expectedEngineIDs { |
| 20 | assert.True(t, slices.Contains(supportedEngines, engineID), "expected engine %q to be registered", engineID) |
| 21 | } |
| 22 | }) |
| 23 | |
| 24 | t.Run("GetEngine returns engine by ID", func(t *testing.T) { |
| 25 | tests := []struct { |
| 26 | engineID string |
| 27 | }{ |
| 28 | {engineID: "claude"}, |
| 29 | {engineID: "codex"}, |
| 30 | {engineID: "copilot"}, |
| 31 | {engineID: "gemini"}, |
| 32 | {engineID: "opencode"}, |
| 33 | {engineID: "crush"}, |
| 34 | } |
| 35 | |
| 36 | for _, tt := range tests { |
| 37 | t.Run(tt.engineID, func(t *testing.T) { |
| 38 | registry := NewEngineRegistry() |
| 39 | engine, err := registry.GetEngine(tt.engineID) |
| 40 | require.NoError(t, err, "GetEngine(%q) should not return an error", tt.engineID) |
| 41 | assert.Equal(t, tt.engineID, engine.GetID(), "engine ID should match requested ID") |
| 42 | }) |
| 43 | } |
| 44 | }) |
| 45 | |
| 46 | t.Run("GetEngine returns error for unknown engine", func(t *testing.T) { |
| 47 | registry := NewEngineRegistry() |
| 48 | _, err := registry.GetEngine("nonexistent") |
| 49 | assert.Error(t, err, "GetEngine should return an error for unknown engine ID") |
| 50 | }) |
| 51 | |
| 52 | t.Run("IsValidEngine", func(t *testing.T) { |
| 53 | registry := NewEngineRegistry() |
| 54 | |
| 55 | validEngines := []string{"claude", "codex", "copilot", "gemini", "opencode", "crush"} |
| 56 | for _, id := range validEngines { |
| 57 | assert.True(t, registry.IsValidEngine(id), "IsValidEngine(%q) should return true", id) |
| 58 | } |
| 59 | |
| 60 | assert.False(t, registry.IsValidEngine("nonexistent"), "IsValidEngine should return false for unknown engine ID") |
| 61 | }) |
| 62 | |
| 63 | t.Run("GetDefaultEngine returns copilot", func(t *testing.T) { |
| 64 | registry := NewEngineRegistry() |
| 65 | defaultEngine := registry.GetDefaultEngine() |
| 66 | require.NotNil(t, defaultEngine, "default engine should not be nil") |
| 67 | assert.Equal(t, "copilot", defaultEngine.GetID(), "default engine should be copilot") |
| 68 | }) |
| 69 | |
| 70 | t.Run("GetEngineByPrefix matches engine", func(t *testing.T) { |
nothing calls this directly
no test coverage detected