Update constructor implementation

This commit is contained in:
kardolus
2023-05-05 13:55:37 -04:00
parent c6977754e6
commit ec26fea3f6
5 changed files with 14 additions and 18 deletions

View File

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

View File

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