-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrequest_test.go
109 lines (92 loc) · 2.17 KB
/
request_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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package abnlookup_test
import (
"os"
"testing"
"time"
"github.com/joshturge/abnlookup"
)
var client *abnlookup.Client
func TestClient(t *testing.T) {
var err error
client, err = abnlookup.NewClient(os.Getenv("AUTH_GUID"), abnlookup.LogDebug)
if err != nil {
t.Error(err)
}
}
func TestSearchByABN(t *testing.T) {
time.Sleep(3 * time.Second)
business, err := client.SearchByABN("12 586 695 715", true)
if err != nil {
t.Error(err)
}
if business.Type.Code == "" {
t.Fail()
}
if business.ABN[0].Value == "" {
t.FailNow()
}
}
func TestSearchByASIC(t *testing.T) {
time.Sleep(3 * time.Second)
business, err := client.SearchByASIC("000 000 019", true)
if err != nil {
t.Error(err)
}
if business.Type.Code == "" {
t.Fail()
}
if business.ABN[0].Value == "" {
t.FailNow()
}
}
func TestSearchByName(t *testing.T) {
time.Sleep(3 * time.Second)
nq := abnlookup.NameQuery{
Postcode: "4156",
LegalName: true,
TradingName: true,
BusinessName: true,
ActiveABNsOnly: false,
StateCodes: []string{"QLD"},
SearchWidth: "typical",
MinimumScore: 20,
MaxResults: 5,
}
people, err := client.SearchByName("Glen", &nq)
if err != nil {
t.Error(err)
}
if len(people) == 0 {
t.Log("Length of people is 0")
t.FailNow()
}
for _, person := range people {
switch {
case person.LegalName != nil:
t.Logf("Person legal name: %s", person.LegalName.FullName)
case person.BusinessName != nil:
t.Logf("Person business name: %s", person.BusinessName.OrganisationName)
case person.MainName != nil:
t.Logf("Person main organisation name: %s", person.MainName.OrganisationName)
default:
t.FailNow()
}
}
}
// This test will test the filterSearch Method which is used by all filter methods including the one below
func TestSearchByABNStatus(t *testing.T) {
abnStatusQuery := abnlookup.ABNStatusQuery{
Postcode: "4156",
ActiveABNsOnly: false,
CurrentGSTRegistrationOnly: false,
EntityTypeCode: "PUB",
}
abnList, err := client.SearchByABNStatus(&abnStatusQuery)
if err != nil {
t.Error(err)
}
if len(abnList) == 0 {
t.Log("length of abn list is 0")
t.Fail()
}
}