-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblacklist_test.go
101 lines (89 loc) · 1.98 KB
/
blacklist_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
package blacklist
import (
"github.com/joho/godotenv"
"log"
"os"
"testing"
)
var cc *Client
var ee error
func TestMain(m *testing.M) {
// Write code here to run before tests
ee = godotenv.Load("vars.env")
if ee != nil {
log.Fatalf("authentication error: %v", ee)
}
cc = NewBlackListClient(os.Getenv("BLACKLIST_BASE_URL"), os.Getenv("BLACKLIST_API_KEY"))
// Run tests
exitVal := m.Run()
// Write code here to run after tests
// Exit with exit value from tests
os.Exit(exitVal)
}
func TestClient_SearchBlacklistFull(t *testing.T) {
tests := []struct {
cl *Client
name string
bvn string
wantErr bool
}{
// TODO: Add test cases.
{cc,
"valid BVN",
os.Getenv("VALID_BVN_NUMBER"),
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := tt.cl.SearchBlacklistFull(tt.bvn)
if (err != nil) != tt.wantErr {
t.Errorf("SearchBlacklistFull() error = %v, wantErr %v", err, tt.wantErr)
return
}
//if !reflect.DeepEqual(gotBlr, tt.wantBlr) {
// t.Errorf("SearchBlacklistFull() gotBlr = %v, want %v", gotBlr, tt.wantBlr)
//}
})
}
}
func TestClient_SearchCRCFull(t *testing.T) {
tests := []struct {
cl *Client
name string
bvn string
wantErr bool
}{
// TODO: Add test cases.
{cc,
"valid BVN",
os.Getenv("VALID_BVN_NUMBER"),
false,
}, // TODO: Add test cases.
{cc,
"Nohit",
os.Getenv("NOHIT"),
false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cd, err := tt.cl.SearchCRCFull(tt.bvn)
if (err != nil) != tt.wantErr {
t.Errorf("searchCRCFull() error = %v, wantErr %v", err, tt.wantErr)
return
}
if cd != nil {
t.Logf("crc result: %+v\n", cd)
}
if tt.name == "Nohit" {
if !cd.NoHit {
t.Errorf("searchCRCFull() cd.Nohit = %v, want true", cd.NoHit)
}
}
//if !reflect.DeepEqual(gotBlr, tt.wantBlr) {
// t.Errorf("SearchBlacklistFull() gotBlr = %v, want %v", gotBlr, tt.wantBlr)
//}
})
}
}