- Introduce newGrokClient and gitRun vars to allow mocking in tests. - Refactor commit, commitmsg, history, prdescribe, and review cmds into separate run funcs. - Update docs, lint, and review to use newGrokClient. - Add comprehensive unit tests in run_test.go covering happy paths, errors, and edge cases. - Expand grok client tests with SSE server mocks for Stream* methods.
17 lines
409 B
Go
17 lines
409 B
Go
package cmd
|
|
|
|
import (
|
|
"gmgauthier.com/grokkit/internal/git"
|
|
"gmgauthier.com/grokkit/internal/grok"
|
|
)
|
|
|
|
// newGrokClient is the factory for the AI client.
|
|
// Tests replace this to inject a mock without making real API calls.
|
|
var newGrokClient = func() grok.AIClient {
|
|
return grok.NewClient()
|
|
}
|
|
|
|
// gitRun is the git command runner.
|
|
// Tests replace this to inject controlled git output.
|
|
var gitRun = git.Run
|