/
candidate_test.go
128 lines (101 loc) · 3.1 KB
/
candidate_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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package blockscore
import "testing"
func init() {
if err := SetKeyEnv(); err != nil {
panic(err)
}
}
var candidateParams = CandidateParams{
NameFirst: "John",
NameLast: "Brendekamp",
Note: "12341234",
Ssn: "0001",
DateOfBirth: "1940-08-11",
AddressStreet1: "1 Infinite Loop",
AddressCity: "Harare",
AddressCountryCode: "ZW",
}
var updateParams = CandidateParams{
Passport: "123456789",
}
var candidateID string
func TestCandidateCreate(t *testing.T) {
resp, err := Candidates.Create(&candidateParams)
if err != nil {
t.Errorf("Expected successful Candidate creation, got Error %s", err.Error())
return
}
candidateID = resp.ID
if resp.NameFirst != candidateParams.NameFirst {
t.Errorf("Expected NameFirst: %s, got: %s", candidateParams.NameFirst, resp.NameFirst)
}
if resp.NameLast != candidateParams.NameLast {
t.Errorf("Expected NameFirst: %s, got: %s", candidateParams.NameLast, resp.NameLast)
}
if resp.Note != candidateParams.Note {
t.Errorf("Expected Note: %s, got: %s", candidateParams.Note, resp.Note)
}
if resp.Ssn != candidateParams.Ssn {
t.Errorf("Expected Ssn: %s, got: %s", candidateParams.Ssn, resp.Ssn)
}
if resp.DateOfBirth != candidateParams.DateOfBirth {
t.Errorf("Expected DateOfBirth: %s, got: %s", candidateParams.DateOfBirth, resp.DateOfBirth)
}
if resp.AddressStreet1 != candidateParams.AddressStreet1 {
t.Errorf("Expected AddressStreet1: %s, got: %s", candidateParams.AddressStreet1, resp.AddressStreet1)
}
if resp.AddressCity != candidateParams.AddressCity {
t.Errorf("Expected AddressCity: %s, got: %s", candidateParams.AddressCity, resp.AddressCity)
}
if resp.AddressCountryCode != candidateParams.AddressCountryCode {
t.Errorf("Expected AddressCountryCode: %s, got: %s", candidateParams.AddressCountryCode, resp.AddressCountryCode)
}
}
func TestRetrieveCandidate(t *testing.T) {
resp, err := Candidates.Retrieve(candidateID)
if err != nil {
t.Errorf("Expected successful Candidate retrieval, got Error: %s", err.Error())
}
if resp.ID != candidateID {
t.Errorf("Expected Candidate with Id: %s, got: %s", candidateID, resp.ID)
}
}
func TestUpdateCandidate(t *testing.T) {
resp, err := Candidates.Update(candidateID, &updateParams)
if err != nil {
t.Errorf("Error: %s", err.Error())
}
if resp.Passport != "123456789" {
t.Errorf("Expected Passport: %s, got: %s", updateParams.Passport, resp.Passport)
}
}
func TestListCandidate(t *testing.T) {
_, err := Candidates.List()
if err != nil {
t.Errorf("Error: %s", err.Error())
}
}
func TestListNCandidate(t *testing.T) {
_, err := Candidates.ListN(2, 5)
if err != nil {
t.Errorf("Error: %s", err.Error())
}
}
func TestHistoryCandidate(t *testing.T) {
_, err := Candidates.History(candidateID)
if err != nil {
t.Errorf("Error: %s", err.Error())
}
}
func TestHitsCandidate(t *testing.T) {
_, err := Candidates.Hits(candidateID)
if err != nil {
t.Errorf("Error: %s", err.Error())
}
}
func TestDeleteCandidate(t *testing.T) {
_, err := Candidates.Delete(candidateID)
if err != nil {
t.Errorf("Error: %s", err.Error())
}
}