forked from raystack/compass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors_test.go
41 lines (36 loc) · 1.06 KB
/
errors_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
package user_test
import (
"testing"
"github.com/goto/compass/core/user"
)
func TestErrors(t *testing.T) {
type testCase struct {
Description string
Err error
ExpectedString string
}
testCases := []testCase{
{
Description: "not found error return correct error string",
Err: user.NotFoundError{Email: "[email protected]"},
ExpectedString: "could not find user with email \"[email protected]\"",
},
{
Description: "duplicate error return correct error string",
Err: user.DuplicateRecordError{Email: "[email protected]"},
ExpectedString: "duplicate user with email \"[email protected]\"",
},
{
Description: "invalid error return correct error string",
Err: user.InvalidError{Email: "[email protected]"},
ExpectedString: "empty field with email \"[email protected]\"",
},
}
for _, tc := range testCases {
t.Run(tc.Description, func(t *testing.T) {
if tc.ExpectedString != tc.Err.Error() {
t.Fatalf("actual is \"%+v\" but expected was \"%+v\"", tc.Err.Error(), tc.ExpectedString)
}
})
}
}