Skip to content

Commit 2610a51

Browse files
committed
rename func to CallAndCheckSuccess
1 parent 673d42a commit 2610a51

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

utils/api/api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ func CheckAPICallSuccess(ctx context.Context, errorContext string, resp *_http.R
5959
return
6060
}
6161

62-
// FetchAndCheckSuccess is a wrapper for making an API call and then checking success with `CheckAPICallSuccess`
62+
// CallAndCheckSuccess is a wrapper for making an API call and then checking success with `CheckAPICallSuccess`
6363
// errorContext corresponds to the description of what led to the error if error there is e.g. `Failed adding a user`.
6464
// apiCallFunc corresponds to a generic function that will be called to make the API call
65-
func FetchAndCheckSuccess[T any](ctx context.Context, errorContext string, apiCallFunc func(ctx context.Context) (T, *_http.Response, error)) (result T, err error) {
65+
func CallAndCheckSuccess[T any](ctx context.Context, errorContext string, apiCallFunc func(ctx context.Context) (T, *_http.Response, error)) (result T, err error) {
6666
if err = parallelisation.DetermineContextError(ctx); err != nil {
6767
return
6868
}

utils/api/api_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ func TestCheckAPICallSuccess(t *testing.T) {
7676
})
7777
}
7878

79-
func TestFetchAndCheckSuccess(t *testing.T) {
79+
func TestCallAndCheckSuccess(t *testing.T) {
8080
t.Run("context cancelled", func(t *testing.T) {
8181
errMessage := "context cancelled"
8282
parentCtx := context.Background()
8383
ctx, cancelCtx := context.WithCancel(parentCtx)
8484
cancelCtx()
85-
_, actualErr := FetchAndCheckSuccess(ctx, errMessage,
85+
_, actualErr := CallAndCheckSuccess(ctx, errMessage,
8686
func(ctx context.Context) (*struct{}, *_http.Response, error) {
8787
return nil, &_http.Response{Body: io.NopCloser(bytes.NewReader(nil))}, errors.New(errMessage)
8888
})
@@ -92,7 +92,7 @@ func TestFetchAndCheckSuccess(t *testing.T) {
9292
t.Run("api call not successful", func(t *testing.T) {
9393
errMessage := "client error"
9494
parentCtx := context.Background()
95-
_, actualErr := FetchAndCheckSuccess(parentCtx, errMessage,
95+
_, actualErr := CallAndCheckSuccess(parentCtx, errMessage,
9696
func(ctx context.Context) (*struct{}, *_http.Response, error) {
9797
resp := _http.Response{StatusCode: 400, Body: io.NopCloser(bytes.NewReader([]byte("{\"message\": \"client error\",\"requestId\": \"761761721\"}")))}
9898
return nil, &resp, errors.New(errMessage)
@@ -104,7 +104,7 @@ func TestFetchAndCheckSuccess(t *testing.T) {
104104
t.Run("no context error, api call successful", func(t *testing.T) {
105105
errMessage := "no error"
106106
parentCtx := context.Background()
107-
_, err := FetchAndCheckSuccess(parentCtx, errMessage,
107+
_, err := CallAndCheckSuccess(parentCtx, errMessage,
108108
func(ctx context.Context) (*struct{}, *_http.Response, error) {
109109
return nil, &_http.Response{StatusCode: 200}, errors.New(errMessage)
110110
})

0 commit comments

Comments
 (0)