Skip to content

Commit 8a1b592

Browse files
Fixed Groq Tests ()
1 parent 81227b7 commit 8a1b592

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

internal/groq/groq.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"net/http"
99
"os"
1010

11-
httpClient "github.com/dfanso/commit-msg/internal/http"
11+
internalHTTP "github.com/dfanso/commit-msg/internal/http"
1212
"github.com/dfanso/commit-msg/pkg/types"
1313
)
1414

@@ -39,8 +39,14 @@ const defaultModel = "llama-3.3-70b-versatile"
3939
var (
4040
// allow overrides in tests
4141
baseURL = "https://api.groq.com/openai/v1/chat/completions"
42+
// httpClient can be overridden in tests; defaults to the internal http client
43+
httpClient *http.Client
4244
)
4345

46+
func init() {
47+
httpClient = internalHTTP.GetClient()
48+
}
49+
4450
// GenerateCommitMessage calls Groq's OpenAI-compatible chat completions API.
4551
func GenerateCommitMessage(_ *types.Config, changes string, apiKey string, opts *types.GenerationOptions) (string, error) {
4652
if changes == "" {
@@ -82,7 +88,7 @@ func GenerateCommitMessage(_ *types.Config, changes string, apiKey string, opts
8288
req.Header.Set("Content-Type", "application/json")
8389
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
8490

85-
resp, err := httpClient.GetClient().Do(req)
91+
resp, err := httpClient.Do(req)
8692
if err != nil {
8793
return "", fmt.Errorf("failed to call Groq API: %w", err)
8894
}

0 commit comments

Comments
 (0)