mirror of
https://github.com/thegeeklab/wp-s3-action.git
synced 2024-06-02 18:39:42 +02:00
use static errors in tests
This commit is contained in:
parent
3c96f333c9
commit
501a7d7d95
|
@ -95,9 +95,3 @@ run:
|
|||
linters-settings:
|
||||
gofumpt:
|
||||
extra-rules: true
|
||||
|
||||
issues:
|
||||
exclude-rules:
|
||||
- path: "_test.go"
|
||||
linters:
|
||||
- err113
|
||||
|
|
|
@ -11,6 +11,8 @@ import (
|
|||
"github.com/thegeeklab/wp-s3-action/aws/mocks"
|
||||
)
|
||||
|
||||
var ErrCreateInvalidation = errors.New("create invalidation failed")
|
||||
|
||||
func TestCloudfront_Invalidate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
@ -48,7 +50,7 @@ func TestCloudfront_Invalidate(t *testing.T) {
|
|||
mockClient := mocks.NewMockCloudfrontAPIClient(t)
|
||||
mockClient.
|
||||
On("CreateInvalidation", mock.Anything, mock.Anything).
|
||||
Return(&cloudfront.CreateInvalidationOutput{}, errors.New("create invalidation failed"))
|
||||
Return(&cloudfront.CreateInvalidationOutput{}, ErrCreateInvalidation)
|
||||
|
||||
return &Cloudfront{
|
||||
client: mockClient,
|
||||
|
|
|
@ -15,6 +15,12 @@ import (
|
|||
"github.com/thegeeklab/wp-s3-action/aws/mocks"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrPutObject = errors.New("put object failed")
|
||||
ErrDeleteObject = errors.New("delete object failed")
|
||||
ErrListObjects = errors.New("list objects failed")
|
||||
)
|
||||
|
||||
func createTempFile(t *testing.T, name string) string {
|
||||
t.Helper()
|
||||
|
||||
|
@ -314,7 +320,7 @@ func TestS3_Redirect(t *testing.T) {
|
|||
mockS3Client := mocks.NewMockS3APIClient(t)
|
||||
mockS3Client.
|
||||
On("PutObject", mock.Anything, mock.Anything).
|
||||
Return(&s3.PutObjectOutput{}, errors.New("put object failed"))
|
||||
Return(&s3.PutObjectOutput{}, ErrPutObject)
|
||||
|
||||
return &S3{
|
||||
client: mockS3Client,
|
||||
|
@ -404,7 +410,7 @@ func TestS3_Delete(t *testing.T) {
|
|||
mockS3Client := mocks.NewMockS3APIClient(t)
|
||||
mockS3Client.
|
||||
On("DeleteObject", mock.Anything, mock.Anything).
|
||||
Return(&s3.DeleteObjectOutput{}, errors.New("delete object failed"))
|
||||
Return(&s3.DeleteObjectOutput{}, ErrDeleteObject)
|
||||
|
||||
return &S3{
|
||||
client: mockS3Client,
|
||||
|
@ -518,7 +524,7 @@ func TestS3_List(t *testing.T) {
|
|||
mockS3Client := mocks.NewMockS3APIClient(t)
|
||||
mockS3Client.
|
||||
On("ListObjects", mock.Anything, mock.Anything).
|
||||
Return(&s3.ListObjectsOutput{}, errors.New("list objects failed"))
|
||||
Return(&s3.ListObjectsOutput{}, ErrListObjects)
|
||||
|
||||
return &S3{
|
||||
client: mockS3Client,
|
||||
|
|
Loading…
Reference in New Issue
Block a user