Skip to content

Commit 9331d33

Browse files
committed
feat: cover kpp test cases
1 parent 355a59b commit 9331d33

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

validator_test.go

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type TestCodeCase struct {
1313
Error error
1414
}
1515

16-
func TestValidateBIK(t *testing.T) {
16+
func TestIsBIKValid(t *testing.T) {
1717
t.Parallel()
1818

1919
t.Run("invalid bik length", func(t *testing.T) {
@@ -40,7 +40,7 @@ func TestValidateBIK(t *testing.T) {
4040
},
4141
}
4242
for _, test := range testCases {
43-
isValid, err := ValidateBIK(test.Code)
43+
isValid, err := IsBIKValid(test.Code)
4444
assert.Equal(t, isValid, test.IsValid, test.Code)
4545
assert.Equal(t, true, errors.Is(test.Error, err), test.Code)
4646
}
@@ -80,14 +80,14 @@ func TestValidateBIK(t *testing.T) {
8080
},
8181
}
8282
for _, test := range testCases {
83-
isValid, err := ValidateBIK(test.Code)
83+
isValid, err := IsBIKValid(test.Code)
8484
assert.Equal(t, isValid, test.IsValid, test.Code, test.IsValid)
8585
assert.Equal(t, true, errors.Is(test.Error, err), test.Code)
8686
}
8787
})
8888
}
8989

90-
func TestValidateINN(t *testing.T) {
90+
func TestIsINNValid(t *testing.T) {
9191
t.Parallel()
9292

9393
t.Run("invalid inn length", func(t *testing.T) {
@@ -114,7 +114,7 @@ func TestValidateINN(t *testing.T) {
114114
},
115115
}
116116
for _, test := range testCases {
117-
isValid, err := ValidateINN(test.Code)
117+
isValid, err := IsINNValid(test.Code)
118118
assert.Equal(t, isValid, test.IsValid, test.Code)
119119
assert.Equal(t, true, errors.Is(test.Error, err), test.Code)
120120
}
@@ -149,7 +149,7 @@ func TestValidateINN(t *testing.T) {
149149
},
150150
}
151151
for _, test := range testCases {
152-
isValid, err := ValidateINN(test.Code)
152+
isValid, err := IsINNValid(test.Code)
153153
assert.Equal(t, isValid, test.IsValid, test.Code)
154154
assert.Equal(t, true, errors.Is(test.Error, err), test.Code)
155155
}
@@ -183,7 +183,33 @@ func TestValidateSNILS(t *testing.T) {
183183
func TestValidateKPP(t *testing.T) {
184184
t.Parallel()
185185

186-
t.Run("", func(t *testing.T) {
187-
186+
t.Run("invalid kpp length", func(t *testing.T) {
187+
testCases := []TestCodeCase{
188+
TestCodeCase{
189+
Code: "1234567888776",
190+
Error: ErrInvalidKPPLength,
191+
IsValid: false,
192+
},
193+
TestCodeCase{
194+
Code: "044525",
195+
Error: ErrInvalidKPPLength,
196+
IsValid: false,
197+
},
198+
TestCodeCase{
199+
Code: "773643301",
200+
Error: nil,
201+
IsValid: true,
202+
},
203+
TestCodeCase{
204+
Code: "773643001",
205+
Error: nil,
206+
IsValid: true,
207+
},
208+
}
209+
for _, test := range testCases {
210+
isValid, err := IsKPPValid(test.Code)
211+
assert.Equal(t, isValid, test.IsValid, test.Code)
212+
assert.Equal(t, true, errors.Is(test.Error, err), test.Code)
213+
}
188214
})
189215
}

0 commit comments

Comments
 (0)