-
Notifications
You must be signed in to change notification settings - Fork 0
/
sii_test.go
36 lines (29 loc) · 888 Bytes
/
sii_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
package gosii
import (
"testing"
)
func TestConsulta_GetNameByRUT(t *testing.T) {
ssiClient := NewClient(nil)
data, _, err := ssiClient.GetNameByRUT("5.126.663-3")
checkResultOk(t, err, data)
data, _, err = ssiClient.GetNameByRUT("5126.6633")
checkResultOk(t, err, data)
data, _, err = ssiClient.GetNameByRUT("51266633")
checkResultOk(t, err, data)
_, _, err = ssiClient.GetNameByRUT("51266633111")
if err == nil {
t.Errorf("GetNameByRUT() error = %v", err)
}
_, _, err = ssiClient.GetNameByRUT("22779893-9")
if err == nil {
t.Errorf("GetNameByRUT() error = %v", err)
}
}
func checkResultOk(t *testing.T, err error, data *Citizen) {
if err != nil {
t.Errorf("GetNameByRUT() error = %v", err)
}
if data.Name != "MIGUEL JUAN SEBASTIAN PINERA ECHENIQUE" {
t.Errorf("GetNameByRUT() got = %v, want %v", data.Name, "MIGUEL JUAN SEBASTIAN PINERA ECHENIQUE")
}
}