Skip to content

Commit

Permalink
chore: refactor mocks to use Store interface
Browse files Browse the repository at this point in the history
  • Loading branch information
kardolus committed Nov 6, 2024
1 parent f8693d4 commit 149e85c
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 106 deletions.
2 changes: 1 addition & 1 deletion api/client/callermocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions api/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"github.com/sclevine/spec/report"
)

//go:generate mockgen -destination=callermocks_test.go -package=client_test github.com/kardolus/chatgpt-cli/http Caller
//go:generate mockgen -destination=historymocks_test.go -package=client_test github.com/kardolus/chatgpt-cli/history HistoryStore
//go:generate mockgen -destination=timermocks_test.go -package=client_test github.com/kardolus/chatgpt-cli/client Timer
//go:generate mockgen -destination=callermocks_test.go -package=client_test github.com/kardolus/chatgpt-cli/api/http Caller
//go:generate mockgen -destination=historymocks_test.go -package=client_test github.com/kardolus/chatgpt-cli/history Store
//go:generate mockgen -destination=timermocks_test.go -package=client_test github.com/kardolus/chatgpt-cli/api/client Timer

const (
envApiKey = "api-key"
Expand All @@ -34,7 +34,7 @@ const (
var (
mockCtrl *gomock.Controller
mockCaller *MockCaller
mockHistoryStore *MockHistoryStore
mockHistoryStore *MockStore
mockTimer *MockTimer
factory *clientFactory
apiKeyEnvVar string
Expand All @@ -52,7 +52,7 @@ func testClient(t *testing.T, when spec.G, it spec.S) {
RegisterTestingT(t)
mockCtrl = gomock.NewController(t)
mockCaller = NewMockCaller(mockCtrl)
mockHistoryStore = NewMockHistoryStore(mockCtrl)
mockHistoryStore = NewMockStore(mockCtrl)
mockTimer = NewMockTimer(mockCtrl)
config = MockConfig()

Expand Down Expand Up @@ -565,10 +565,10 @@ func createMessages(historyEntries []history.History, query string) []api.Messag
}

type clientFactory struct {
mockHistoryStore *MockHistoryStore
mockHistoryStore *MockStore
}

func newClientFactory(mhs *MockHistoryStore) *clientFactory {
func newClientFactory(mhs *MockStore) *clientFactory {
return &clientFactory{
mockHistoryStore: mhs,
}
Expand Down
60 changes: 30 additions & 30 deletions api/client/historymocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/client/timermocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 31 additions & 31 deletions config/configmocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions config/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/sclevine/spec/report"
)

//go:generate mockgen -destination=configmocks_test.go -package=configmanager_test github.com/kardolus/chatgpt-cli/config ConfigStore
//go:generate mockgen -destination=configmocks_test.go -package=config_test github.com/kardolus/chatgpt-cli/config Store

func TestUnitConfigManager(t *testing.T) {
spec.Run(t, "Config Manager", testConfig, spec.Report(report.Terminal{}))
Expand Down Expand Up @@ -48,15 +48,15 @@ func testConfig(t *testing.T, when spec.G, it spec.S) {

var (
mockCtrl *gomock.Controller
mockConfigStore *MockConfigStore
mockConfigStore *MockStore
defaultConfig config.Config
envPrefix string
)

it.Before(func() {
RegisterTestingT(t)
mockCtrl = gomock.NewController(t)
mockConfigStore = NewMockConfigStore(mockCtrl)
mockConfigStore = NewMockStore(mockCtrl)

defaultConfig = config.Config{
Name: defaultName,
Expand Down
Loading

0 comments on commit 149e85c

Please sign in to comment.