@@ -68,6 +68,42 @@ func TestCleanCommitMessage(t *testing.T) {
6868 }
6969}
7070
71+ // resolveProviderCommand returns the command for a given provider and whether it's a Claude provider.
72+ func resolveProviderCommand (provider string ) (string , bool ) {
73+ switch {
74+ case strings .HasPrefix (provider , "claude" ):
75+ return "claude" , true
76+ case provider == "gemini" :
77+ return "gemini" , false
78+ case provider == "copilot" :
79+ return "copilot" , false
80+ default :
81+ return "" , false
82+ }
83+ }
84+
85+ // validateProviderMapping validates that a provider maps to the expected command.
86+ func validateProviderMapping (t * testing.T , provider , expectedCmd string , actualCmd string , isClaude bool ) {
87+ switch {
88+ case strings .HasPrefix (provider , "claude" ):
89+ if ! isClaude {
90+ t .Errorf ("Provider %s should be recognized as claude provider" , provider )
91+ }
92+ if actualCmd != "claude" {
93+ t .Errorf ("Provider %s should map to 'claude' command, got %s" , provider , actualCmd )
94+ }
95+ case provider == "gemini" || provider == "copilot" :
96+ if provider != expectedCmd {
97+ t .Errorf ("Provider %s should map to '%s' command, got %s" , provider , expectedCmd , actualCmd )
98+ }
99+ default :
100+ // Unsupported providers
101+ if isClaude || actualCmd != "" {
102+ t .Errorf ("Provider %s should be unsupported" , provider )
103+ }
104+ }
105+ }
106+
71107func TestProviderValidation (t * testing.T ) {
72108 tests := []struct {
73109 provider string
@@ -98,43 +134,8 @@ func TestProviderValidation(t *testing.T) {
98134
99135 for _ , tt := range tests {
100136 t .Run (tt .provider , func (t * testing.T ) {
101- // Test provider validation logic
102- var isClaudeProvider bool
103- var command string
104-
105- switch {
106- case strings .HasPrefix (tt .provider , "claude" ):
107- isClaudeProvider = true
108- command = "claude"
109- case tt .provider == "gemini" :
110- isClaudeProvider = false
111- command = "gemini"
112- case tt .provider == "copilot" :
113- isClaudeProvider = false
114- command = "copilot"
115- default :
116- isClaudeProvider = false
117- command = ""
118- }
119-
120- // For claude-prefixed providers, we expect them to be supported
121- if strings .HasPrefix (tt .provider , "claude" ) {
122- if ! isClaudeProvider {
123- t .Errorf ("Provider %s should be recognized as claude provider" , tt .provider )
124- }
125- if command != "claude" {
126- t .Errorf ("Provider %s should map to 'claude' command, got %s" , tt .provider , command )
127- }
128- } else if tt .provider == "gemini" || tt .provider == "copilot" {
129- if tt .provider != "gemini" && tt .provider != "copilot" {
130- t .Errorf ("Provider %s should be handled separately" , tt .provider )
131- }
132- } else {
133- // Unsupported providers
134- if isClaudeProvider || command != "" {
135- t .Errorf ("Provider %s should be unsupported" , tt .provider )
136- }
137- }
137+ command , isClaude := resolveProviderCommand (tt .provider )
138+ validateProviderMapping (t , tt .provider , tt .expectedCmd , command , isClaude )
138139
139140 // Validate expected behavior
140141 if tt .isSupported && command == "" && ! strings .HasPrefix (tt .provider , "claude" ) {
@@ -271,7 +272,7 @@ func TestGitRepositoryDetection(t *testing.T) {
271272 var _ bool = isGitRepo ()
272273}
273274
274- // Edge case tests
275+ // Edge case tests.
275276func TestEdgeCases (t * testing.T ) {
276277 t .Run ("empty analysis input" , func (t * testing.T ) {
277278 // Test that empty analysis input is handled
@@ -309,7 +310,7 @@ Git diff analysis:
309310 })
310311}
311312
312- // Performance tests
313+ // Performance tests.
313314func BenchmarkCleanCommitMessageSimple (b * testing.B ) {
314315 message := "feat: add new feature"
315316 for i := 0 ; i < b .N ; i ++ {
0 commit comments