Skip to content

Commit fd22c2b

Browse files
committed
use AssertError in test
1 parent 4f2b79b commit fd22c2b

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

utils/api/api_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/stretchr/testify/assert"
1717

1818
"github.com/ARM-software/golang-utils/utils/commonerrors"
19+
"github.com/ARM-software/golang-utils/utils/commonerrors/errortest"
1920
)
2021

2122
func TestIsAPICallSuccessful(t *testing.T) {
@@ -46,7 +47,8 @@ func TestCheckAPICallSuccess(t *testing.T) {
4647
cancelCtx()
4748
respBody := _http.Response{Body: io.NopCloser(bytes.NewReader(nil))}
4849
actualErr := CheckAPICallSuccess(ctx, errMessage, &respBody, errors.New(errMessage))
49-
assert.True(t, commonerrors.Any(actualErr, commonerrors.ErrCancelled))
50+
errortest.AssertError(t, actualErr, commonerrors.ErrCancelled)
51+
5052
})
5153

5254
t.Run("api call not successful", func(t *testing.T) {
@@ -86,7 +88,7 @@ func TestCallAndCheckSuccess(t *testing.T) {
8688
func(ctx context.Context) (*struct{}, *_http.Response, error) {
8789
return nil, &_http.Response{Body: io.NopCloser(bytes.NewReader(nil))}, errors.New(errMessage)
8890
})
89-
assert.True(t, commonerrors.Any(actualErr, commonerrors.ErrCancelled))
91+
errortest.AssertError(t, actualErr, commonerrors.ErrCancelled)
9092
})
9193

9294
t.Run("api call not successful", func(t *testing.T) {
@@ -118,6 +120,6 @@ func TestCallAndCheckSuccess(t *testing.T) {
118120
func(ctx context.Context) (*struct{}, *_http.Response, error) {
119121
return &struct{}{}, &_http.Response{StatusCode: 200}, errors.New(errMessage)
120122
})
121-
assert.True(t, commonerrors.Any(err, commonerrors.ErrMarshalling))
123+
errortest.AssertError(t, err, commonerrors.ErrMarshalling)
122124
})
123125
}

0 commit comments

Comments
 (0)