mirror of
https://github.com/kardolus/chatgpt-cli.git
synced 2024-09-08 23:15:00 +03:00
Fix bug around obtaining default values
This commit is contained in:
@@ -30,19 +30,12 @@ type Client struct {
|
||||
historyStore history.HistoryStore
|
||||
}
|
||||
|
||||
func New(caller http.Caller, cs config.ConfigStore, hs history.HistoryStore) (*Client, error) {
|
||||
cm, err := configmanager.New(cs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := &Client{
|
||||
Config: cm.Config,
|
||||
func New(caller http.Caller, cs config.ConfigStore, hs history.HistoryStore) *Client {
|
||||
return &Client{
|
||||
Config: configmanager.New(cs).Config,
|
||||
caller: caller,
|
||||
historyStore: hs,
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *Client) WithCapacity(capacity int) *Client {
|
||||
|
||||
@@ -466,7 +466,7 @@ func newClientFactory(mc *MockCaller, mcs *MockConfigStore, mhs *MockHistoryStor
|
||||
URL: defaultURL,
|
||||
CompletionsPath: defaultCompletionsPath,
|
||||
ModelsPath: defaultModelsPath,
|
||||
}, nil).Times(1)
|
||||
}).Times(1)
|
||||
|
||||
return &clientFactory{
|
||||
mockCaller: mc,
|
||||
@@ -478,8 +478,7 @@ func newClientFactory(mc *MockCaller, mcs *MockConfigStore, mhs *MockHistoryStor
|
||||
func (f *clientFactory) buildClientWithoutConfig() *client.Client {
|
||||
f.mockConfigStore.EXPECT().Read().Return(types.Config{}, nil).Times(1)
|
||||
|
||||
c, err := client.New(f.mockCaller, f.mockConfigStore, f.mockHistoryStore)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
c := client.New(f.mockCaller, f.mockConfigStore, f.mockHistoryStore)
|
||||
|
||||
return c.WithCapacity(50)
|
||||
}
|
||||
@@ -487,9 +486,8 @@ func (f *clientFactory) buildClientWithoutConfig() *client.Client {
|
||||
func (f *clientFactory) buildClientWithConfig(config types.Config) *client.Client {
|
||||
f.mockConfigStore.EXPECT().Read().Return(config, nil).Times(1)
|
||||
|
||||
c, err := client.New(f.mockCaller, f.mockConfigStore, f.mockHistoryStore)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
c := client.New(f.mockCaller, f.mockConfigStore, f.mockHistoryStore)
|
||||
|
||||
return c.WithCapacity(50)
|
||||
}
|
||||
|
||||
|
||||
@@ -50,12 +50,11 @@ func (mr *MockConfigStoreMockRecorder) Read() *gomock.Call {
|
||||
}
|
||||
|
||||
// ReadDefaults mocks base method.
|
||||
func (m *MockConfigStore) ReadDefaults() (types.Config, error) {
|
||||
func (m *MockConfigStore) ReadDefaults() types.Config {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ReadDefaults")
|
||||
ret0, _ := ret[0].(types.Config)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ReadDefaults indicates an expected call of ReadDefaults.
|
||||
|
||||
Reference in New Issue
Block a user