@@ -42,13 +42,8 @@ func TestAccScalewayCassettes_Validator(t *testing.T) {
42
42
43
43
func checkErrorCode (c * cassette.Cassette ) error {
44
44
for _ , i := range c .Interactions {
45
- switch i .Code {
46
- case http .StatusInternalServerError :
45
+ if ! checkErrCode (i , c , http .StatusConflict , http .StatusInternalServerError ) {
47
46
return fmt .Errorf ("status: %v founded on %s. method: %s, url %s" , i .Code , c .Name , i .Request .Method , i .Request .URL )
48
- case http .StatusConflict :
49
- if ! checkExceptions (c ) {
50
- return fmt .Errorf ("status: %v founded on %s. method: %s, url %s" , i .Code , c .Name , i .Request .Method , i .Request .URL )
51
- }
52
47
}
53
48
}
54
49
@@ -62,11 +57,22 @@ func exceptionsCassettesCases() map[string]struct{} {
62
57
"testdata/data-source-rdb-privilege-basic.cassette.yaml" : {}}
63
58
}
64
59
65
- func checkExceptions ( c * cassette.Cassette ) bool {
60
+ func checkErrCode ( i * cassette. Interaction , c * cassette.Cassette , codes ... int ) bool {
66
61
exceptions := exceptionsCassettesCases ()
67
- _ , exist := exceptions [c .File ]
68
- return exist
62
+ _ , isException := exceptions [c .File ]
63
+ if isException {
64
+ return isException
65
+ }
66
+
67
+ for _ , httpCode := range codes {
68
+ if i .Code == httpCode {
69
+ return true
70
+ }
71
+ }
72
+
73
+ return true
69
74
}
75
+
70
76
func fileNameWithoutExtSuffix (fileName string ) string {
71
77
return strings .TrimSuffix (fileName , filepath .Ext (fileName ))
72
78
}
0 commit comments