Skip to content

Commit e5fa376

Browse files
committed
feat: bik coverage
1 parent 76f8efc commit e5fa376

File tree

1 file changed

+77
-11
lines changed

1 file changed

+77
-11
lines changed

validator_test.go

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,74 @@ type TestCodeCase struct {
1616
func TestValidateBIK(t *testing.T) {
1717
t.Parallel()
1818

19-
t.Run("", func(t *testing.T) {
19+
t.Run("invalid bik length", func(t *testing.T) {
20+
testCases := []TestCodeCase{
21+
TestCodeCase{
22+
Code: "1234567888776",
23+
Error: ErrInvalidBIKLength,
24+
IsValid: false,
25+
},
26+
TestCodeCase{
27+
Code: "044525",
28+
Error: ErrInvalidBIKLength,
29+
IsValid: false,
30+
},
31+
TestCodeCase{
32+
Code: "044525225",
33+
Error: nil,
34+
IsValid: true,
35+
},
36+
TestCodeCase{
37+
Code: "044525012",
38+
Error: nil,
39+
IsValid: true,
40+
},
41+
}
42+
for _, test := range testCases {
43+
isValid, err := ValidateBIK(test.Code)
44+
assert.Equal(t, isValid, test.IsValid, test.Code)
45+
assert.Equal(t, true, errors.Is(test.Error, err), test.Code)
46+
}
47+
})
2048

49+
t.Run("invalid bik value", func(t *testing.T) {
50+
testCases := []TestCodeCase{
51+
TestCodeCase{
52+
Code: "0445?5226",
53+
Error: ErrInvalidValue,
54+
IsValid: false,
55+
},
56+
TestCodeCase{
57+
Code: "054525225",
58+
Error: ErrInvalidBIKCountryCode,
59+
IsValid: false,
60+
},
61+
TestCodeCase{
62+
Code: "104525225",
63+
Error: ErrInvalidBIKCountryCode,
64+
IsValid: false,
65+
},
66+
TestCodeCase{
67+
Code: "044#55#25",
68+
Error: ErrInvalidValue,
69+
IsValid: false,
70+
},
71+
TestCodeCase{
72+
Code: "044525225",
73+
Error: nil,
74+
IsValid: true,
75+
},
76+
TestCodeCase{
77+
Code: "044525012",
78+
Error: nil,
79+
IsValid: true,
80+
},
81+
}
82+
for _, test := range testCases {
83+
isValid, err := ValidateBIK(test.Code)
84+
assert.Equal(t, isValid, test.IsValid, test.Code, test.IsValid)
85+
assert.Equal(t, true, errors.Is(test.Error, err), test.Code)
86+
}
2187
})
2288
}
2389

@@ -28,12 +94,12 @@ func TestValidateINN(t *testing.T) {
2894
testCases := []TestCodeCase{
2995
TestCodeCase{
3096
Code: "12345678",
31-
Error: errInvalidINNLength,
97+
Error: ErrInvalidINNLength,
3298
IsValid: false,
3399
},
34100
TestCodeCase{
35101
Code: "9876543211123",
36-
Error: errInvalidINNLength,
102+
Error: ErrInvalidINNLength,
37103
IsValid: false,
38104
},
39105
TestCodeCase{
@@ -48,27 +114,27 @@ func TestValidateINN(t *testing.T) {
48114
},
49115
}
50116
for _, test := range testCases {
51-
isValid, err := ValidateINN(test.INN)
52-
assert.Equal(t, isValid, test.IsValid)
53-
assert.Equal(t, errors.Is(test.Error, err), true)
117+
isValid, err := ValidateINN(test.Code)
118+
assert.Equal(t, isValid, test.IsValid, test.Code)
119+
assert.Equal(t, true, errors.Is(test.Error, err), test.Code)
54120
}
55121
})
56122

57123
t.Run("invalid inn value", func(t *testing.T) {
58124
testCases := []TestCodeCase{
59125
TestCodeCase{
60126
Code: "77$7083893",
61-
Error: errInvalidValue,
127+
Error: ErrInvalidValue,
62128
IsValid: false,
63129
},
64130
TestCodeCase{
65131
Code: "98754321N123",
66-
Error: errInvalidValue,
132+
Error: ErrInvalidValue,
67133
IsValid: false,
68134
},
69135
TestCodeCase{
70136
Code: "9854132d1123",
71-
Error: errInvalidValue,
137+
Error: ErrInvalidValue,
72138
IsValid: false,
73139
},
74140
TestCodeCase{
@@ -84,8 +150,8 @@ func TestValidateINN(t *testing.T) {
84150
}
85151
for _, test := range testCases {
86152
isValid, err := ValidateINN(test.Code)
87-
assert.Equal(t, isValid, test.IsValid)
88-
assert.Equal(t, errors.Is(test.Error, err), true)
153+
assert.Equal(t, isValid, test.IsValid, test.Code)
154+
assert.Equal(t, true, errors.Is(test.Error, err), test.Code)
89155
}
90156
})
91157
}

0 commit comments

Comments
 (0)