-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrorMap_test.go
More file actions
37 lines (33 loc) · 847 Bytes
/
errorMap_test.go
File metadata and controls
37 lines (33 loc) · 847 Bytes
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
package validator
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestErrorMap(t *testing.T) {
testCases := []struct {
name string
input errorMap
expected map[string]string
}{
{
name: "empty error map",
input: errorMap{},
expected: map[string]string{},
},
{
name: "error map with one error",
input: errorMap{"email": ErrEmailNotValid},
expected: map[string]string{"email": ErrEmailNotValid.Error()},
},
{
name: "error map with multiple errors",
input: errorMap{"email": ErrEmailNotValid, "phone": ErrNotEmptyField},
expected: map[string]string{"email": ErrEmailNotValid.Error(), "phone": ErrNotEmptyField.Error()},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.input.Error(), tc.expected)
})
}
}