github.com/prebid/prebid-server/v2@v2.18.0/errortypes/code_test.go (about) 1 package errortypes 2 3 import ( 4 "errors" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestReadCodeWithCodeDefined(t *testing.T) { 11 err := &Timeout{Message: "code is defined"} 12 13 result := ReadCode(err) 14 15 assert.Equal(t, result, TimeoutErrorCode) 16 } 17 18 func TestReadCodeWithCodeNotDefined(t *testing.T) { 19 err := errors.New("missing error code") 20 21 result := ReadCode(err) 22 23 assert.Equal(t, result, UnknownErrorCode) 24 }