-
Notifications
You must be signed in to change notification settings - Fork 39
/
financialInstitution_test.go
80 lines (75 loc) · 1.68 KB
/
financialInstitution_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package wire
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestFinancialInstitution_Validate(t *testing.T) {
tests := []struct {
desc string
fi FinancialInstitution
wantErr string
}{
{
desc: "empty model is valid",
fi: FinancialInstitution{},
},
{
desc: "IDCode without ID",
fi: FinancialInstitution{
IdentificationCode: CHIPSIdentifier,
},
wantErr: fieldError("Identifier", ErrFieldRequired).Error(),
},
{
desc: "ID without IDCode",
fi: FinancialInstitution{
Identifier: "someIdentifier",
},
wantErr: fieldError("IdentificationCode", ErrFieldRequired).Error(),
},
{
desc: "invalid chars in name",
fi: FinancialInstitution{
Name: "ℯⰰ",
},
wantErr: fieldError("Name", ErrNonAlphanumeric, "ℯⰰ").Error(),
},
{
desc: "invalid chars in address 1",
fi: FinancialInstitution{
Address: Address{
AddressLineOne: "ℯⰰ",
},
},
wantErr: fieldError("AddressLineOne", ErrNonAlphanumeric, "ℯⰰ").Error(),
},
{
desc: "invalid chars in address 2",
fi: FinancialInstitution{
Address: Address{
AddressLineTwo: "ℯⰰ",
},
},
wantErr: fieldError("AddressLineTwo", ErrNonAlphanumeric, "ℯⰰ").Error(),
},
{
desc: "invalid chars in address 3",
fi: FinancialInstitution{
Address: Address{
AddressLineThree: "ℯⰰ",
},
},
wantErr: fieldError("AddressLineThree", ErrNonAlphanumeric, "ℯⰰ").Error(),
},
}
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
got := tt.fi.Validate()
if tt.wantErr != "" {
require.ErrorContains(t, got, tt.wantErr)
} else {
require.NoError(t, got)
}
})
}
}