mirror of
https://github.com/kardolus/chatgpt-cli.git
synced 2024-09-08 23:15:00 +03:00
Update constructor implementation
This commit is contained in:
@@ -29,15 +29,7 @@ type Client struct {
|
||||
capacity int
|
||||
}
|
||||
|
||||
func New(caller http.Caller, rw history.Store, capacity int) *Client {
|
||||
return &Client{
|
||||
caller: caller,
|
||||
readWriter: rw,
|
||||
capacity: capacity,
|
||||
}
|
||||
}
|
||||
|
||||
func NewDefault(caller http.Caller, rw history.Store) *Client {
|
||||
func New(caller http.Caller, rw history.Store) *Client {
|
||||
return &Client{
|
||||
caller: caller,
|
||||
readWriter: rw,
|
||||
@@ -45,6 +37,11 @@ func NewDefault(caller http.Caller, rw history.Store) *Client {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) WithCapacity(capacity int) *Client {
|
||||
c.capacity = capacity
|
||||
return c
|
||||
}
|
||||
|
||||
// Query sends a query to the API and returns the response as a string.
|
||||
// It takes an input string as a parameter and returns a string containing
|
||||
// the API response or an error if there's any issue during the process.
|
||||
|
||||
@@ -36,7 +36,7 @@ func testClient(t *testing.T, when spec.G, it spec.S) {
|
||||
mockCtrl = gomock.NewController(t)
|
||||
mockCaller = NewMockCaller(mockCtrl)
|
||||
mockStore = NewMockStore(mockCtrl)
|
||||
subject = client.New(mockCaller, mockStore, 50)
|
||||
subject = client.New(mockCaller, mockStore).WithCapacity(50)
|
||||
})
|
||||
|
||||
it.After(func() {
|
||||
|
||||
Reference in New Issue
Block a user