-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_test.go
46 lines (37 loc) · 1.24 KB
/
account_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
package account
import (
"testing"
"gotest.tools/v3/assert"
)
func TestAccountCreated(t *testing.T) {
account, err := CreateAccountNumber("KZ", "TP", 7399051)
assert.NilError(t, err)
assert.Equal(t, *account, "KZ98TPAC000007399051")
}
func TestAccountValid(t *testing.T) {
assert.Equal(t, IsValid("KZ86TPAC000000000010"), true)
}
func TestAccountInvalid(t *testing.T) {
assert.Equal(t, IsValid("KZ93TPAC000000000010"), false)
}
func TestAccountInvalidByLength(t *testing.T) {
assert.Equal(t, IsValid("KZ93TPAC00010"), false)
}
func TestAccountNotCreatedBecauseOfCountry(t *testing.T) {
_, err := CreateAccountNumber("KZT", "TP", 10)
assert.ErrorIs(t, err, ErrInvalidArgument)
_, err = CreateAccountNumber("K", "TP", 10)
assert.ErrorIs(t, err, ErrInvalidArgument)
}
func TestAccountNotCreatedBecauseOfOrg(t *testing.T) {
_, err := CreateAccountNumber("KZ", "TPS", 10)
assert.ErrorIs(t, err, ErrInvalidArgument)
_, err = CreateAccountNumber("KZ", "T", 10)
assert.ErrorIs(t, err, ErrInvalidArgument)
}
func TestAccountNotCreatedBecauseOfId(t *testing.T) {
_, err := CreateAccountNumber("KZ", "TP", 0)
assert.ErrorIs(t, err, ErrIdOutOfRange)
_, err = CreateAccountNumber("KZ", "TP", 1000000000000)
assert.ErrorIs(t, err, ErrIdOutOfRange)
}