...
1 package datasource
2
3 import (
4 "strconv"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 )
9
10 func TestHTTPStatusError(t *testing.T) {
11 var error = httpStatusError{Message: "message", Code: 500}
12 assert.Equal(t, "message", error.Error())
13 }
14
15 func TestIsHTTPErrorRecoverable(t *testing.T) {
16 for i := 400; i < 500; i++ {
17 assert.Equal(t, i == 400 || i == 408 || i == 429, isHTTPErrorRecoverable(i), strconv.Itoa(i))
18 }
19 for i := 500; i < 600; i++ {
20 assert.True(t, isHTTPErrorRecoverable(i))
21 }
22 }
23
24 func TestHTTPErrorDescription(t *testing.T) {
25 assert.Equal(t, "HTTP error 400", httpErrorDescription(400))
26 assert.Equal(t, "HTTP error 401 (invalid SDK key)", httpErrorDescription(401))
27 assert.Equal(t, "HTTP error 403 (invalid SDK key)", httpErrorDescription(403))
28 assert.Equal(t, "HTTP error 500", httpErrorDescription(500))
29 }
30
View as plain text