Skip to content

Commit 669d562

Browse files
committed
fix: add an exception for NonExistentQueue response code
1 parent db4cb09 commit 669d562

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scaleway/validate_cassettes_test.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010
"testing"
1111

12+
"github.com/aws/aws-sdk-go/service/sqs"
1213
"github.com/dnaeon/go-vcr/cassette"
1314
"github.com/stretchr/testify/assert"
1415
)
@@ -43,8 +44,9 @@ func TestAccScalewayCassettes_Validator(t *testing.T) {
4344

4445
func checkErrorCode(c *cassette.Cassette) error {
4546
for _, i := range c.Interactions {
46-
if !checkErrCodeExcept(i, c, http.StatusNotFound, http.StatusTooManyRequests, http.StatusForbidden) &&
47-
!isTransientStateError(i) {
47+
isGoodErrorCode := checkErrCodeExcept(i, c, http.StatusNotFound, http.StatusTooManyRequests, http.StatusForbidden)
48+
49+
if !isGoodErrorCode && !isTransientStateError(i) {
4850
return fmt.Errorf("status: %v found on %s. method: %s, url %s\nrequest body = %v\nresponse body = %v", i.Code, c.Name, i.Request.Method, i.Request.URL, i.Request.Body, i.Response.Body)
4951
}
5052
}
@@ -68,6 +70,11 @@ func checkErrCodeExcept(i *cassette.Interaction, c *cassette.Cassette, codes ...
6870
return isException
6971
}
7072

73+
// SQS returns 400 when the queue does not exist
74+
if strings.Contains(i.Response.Body, sqs.ErrCodeQueueDoesNotExist) && i.Code == 400 {
75+
return true
76+
}
77+
7178
if i.Code >= 400 {
7279
for _, httpCode := range codes {
7380
if i.Code == httpCode {

0 commit comments

Comments
 (0)