Skip to content

Commit 2693df0

Browse files
committed
add: tests
1 parent 494ce69 commit 2693df0

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

generate.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ func Generate(docType DocType) string {
1717
callFunc = inn.Generate
1818
case KPP:
1919
callFunc = kpp.Generate
20-
default:
21-
panic("not implemented method")
2220
}
2321

2422
if callFunc == nil {

generate_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
package docs_code
22

3-
import "testing"
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
48

59
func Test_Generate(t *testing.T) {
10+
inn := Generate(INN)
11+
isValid, err := Validate(INN, inn)
12+
require.NoError(t, err)
13+
14+
require.True(t, isValid)
15+
}
616

17+
func Test_Generate_Unsupported(t *testing.T) {
18+
require.Panics(t, func() {
19+
Generate(DocType(100500))
20+
})
721
}

validate.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ func Validate(docType DocType, code string) (bool, error) {
1717
callFunc = inn.Validate
1818
case KPP:
1919
callFunc = kpp.Validate
20-
default:
21-
panic("not implemented method")
2220
}
2321

2422
if callFunc == nil {

validate_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
package docs_code
22

3-
import "testing"
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
48

59
func Test_Validate(t *testing.T) {
10+
isValid, err := Validate(INN, "7707083893")
11+
require.NoError(t, err)
12+
13+
require.True(t, isValid)
14+
}
615

16+
func Test_Validate_Unsupported(t *testing.T) {
17+
require.Panics(t, func() {
18+
Validate(DocType(100500), "100500")
19+
})
720
}

0 commit comments

Comments
 (0)