-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathorganization_test.go
55 lines (46 loc) · 1.58 KB
/
organization_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
package personnummer
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestIsValidOrganisation(t *testing.T) {
cases := []struct {
organizationNumber string
valid bool
}{
{organizationNumber: "16556703-7485", valid: true},
{organizationNumber: "556703-7485", valid: true},
{organizationNumber: "556074-7569", valid: true},
{organizationNumber: "252002-6135", valid: true},
{organizationNumber: "056703-7486", valid: false},
{organizationNumber: "8001013294", valid: false},
{organizationNumber: "556703+7485", valid: false},
{organizationNumber: "19556703-7485", valid: false},
{organizationNumber: "😸", valid: false},
}
for _, tc := range cases {
t.Run(fmt.Sprintf("%s is %v", tc.organizationNumber, tc.valid), func(t *testing.T) {
valid := IsValidOrganization(tc.organizationNumber)
assert.Equal(t, tc.valid, valid)
})
}
}
func TestOrganizationCorporateForm(t *testing.T) {
cases := []struct {
organizationNumber string
corporateForm CorporateForm
}{
{organizationNumber: "556703-7485", corporateForm: CorporateFormLimitedCompany},
{organizationNumber: "252002-6135", corporateForm: CorporateFormStateCCMunicipalities},
{organizationNumber: "802405-0190", corporateForm: CorporateFormIdealFoundation},
}
for _, tc := range cases {
t.Run(fmt.Sprintf("%s is %s", tc.organizationNumber, tc.corporateForm), func(t *testing.T) {
org, err := NewOrganization(tc.organizationNumber)
require.NoError(t, err)
assert.Equal(t, tc.corporateForm, org.CorporateForm)
})
}
}