Fix bug around obtaining default values

This commit is contained in:
kardolus
2023-06-18 00:06:22 -04:00
parent 0c6e5928ac
commit 8d1eef1611
14 changed files with 62 additions and 92 deletions

View File

@@ -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 {

View File

@@ -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)
}

View File

@@ -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.