...
1 package evaluation
2
3 import (
4 "errors"
5 "fmt"
6 "testing"
7
8 "github.com/launchdarkly/go-sdk-common/v3/ldreason"
9
10 "github.com/stretchr/testify/assert"
11 )
12
13 func TestErrorKindForError(t *testing.T) {
14 for _, err := range []error{
15 badAttrRefError("x"),
16 badVariationError(1),
17 circularPrereqReferenceError("x"),
18 emptyRolloutError{},
19 malformedSegmentError{"x", nil},
20 } {
21 t.Run(fmt.Sprintf("%+v", err), func(t *testing.T) {
22 assert.Equal(t, ldreason.EvalErrorMalformedFlag, errorKindForError(err))
23 })
24 }
25
26 assert.Equal(t, ldreason.EvalErrorException, errorKindForError(errors.New("some other error")))
27 }
28
View as plain text