forked from prebid/prebid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresponse_test.go
43 lines (38 loc) · 1.1 KB
/
response_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package adapters
import (
"testing"
"github.com/prebid/prebid-server/v3/errortypes"
"github.com/stretchr/testify/assert"
)
func TestCheckResponseStatusCodeForErrors(t *testing.T) {
testCases := []struct {
name string
responseStatus int
expectedErr error
}{
{
name: "bad_input",
responseStatus: 400,
expectedErr: &errortypes.BadInput{
Message: "Unexpected status code: 400. Run with request.debug = 1 for more info",
},
},
{
name: "internal_server_error",
responseStatus: 500,
expectedErr: &errortypes.BadServerResponse{
Message: "Unexpected status code: 500. Run with request.debug = 1 for more info",
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := CheckResponseStatusCodeForErrors(&ResponseData{StatusCode: tc.responseStatus})
assert.Equal(t, tc.expectedErr, err)
})
}
}
func TestIsResponseStatusCodeNoContent(t *testing.T) {
assert.True(t, IsResponseStatusCodeNoContent(&ResponseData{StatusCode: 204}))
assert.False(t, IsResponseStatusCodeNoContent(&ResponseData{StatusCode: 200}))
}