Configure HttpClient, added context parameter to all methods (#37)

Context is needed to limit time of execution of a method. Previously, context was passed to structure and it was stored inside structure which is a bad practice. Now we need to pass context to function, which is a best practice
This commit is contained in:
Kirill
2023-08-05 13:50:34 +03:00
committed by GitHub
parent 018d40e641
commit 854d110ab1
41 changed files with 698 additions and 493 deletions

View File

@@ -1,6 +1,7 @@
package ozon
import (
"context"
"net/http"
"testing"
@@ -52,7 +53,8 @@ func TestListCertifiedBrands(t *testing.T) {
for _, test := range tests {
c := NewMockClient(core.NewMockHttpHandler(test.statusCode, test.response, test.headers))
resp, err := c.Brands().List(test.params)
ctx, _ := context.WithTimeout(context.Background(), testTimeout)
resp, err := c.Brands().List(ctx, test.params)
if err != nil {
t.Error(err)
}