-
Notifications
You must be signed in to change notification settings - Fork 3
/
fullcontact_test.go
53 lines (43 loc) · 1.25 KB
/
fullcontact_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
package fullcontact
import (
"net/http"
"os"
"testing"
)
// TODO: need to get a public api key for testing
func TestNewClient(t *testing.T) {
client, err := NewClient("")
if err != nil {
t.Errorf("New Client: %s", err.Error())
return
}
if os.Getenv("FULLCONTACT_API") == "" {
t.Skip("FULLCONTACT_API environment variable not set.")
}
req404, _ := http.NewRequest("GET", "https://api.fullcontact.com/v3", nil)
_, err404 := client.do(req404)
if err404 != ErrStatus404 {
t.Errorf("Expected 404 from FullContact")
return
}
req403, _ := http.NewRequest("GET", "https://api.fullcontact.com/v2/company/lookup.json?domain=github.com&apiKey=abd123", nil)
_, err403 := client.do(req403)
if err403 != ErrStatus403 {
t.Errorf("Expected 403 from FullContact")
return
}
req405, _ := http.NewRequest("DELETE", "https://api.fullcontact.com/v2/company/lookup.json?domain=github.com&apiKey=abd123", nil)
_, err405 := client.do(req405)
if err405 != ErrStatus405 {
t.Errorf("Expected 405 from FullContact. Only GET and POST methods are allowed")
return
}
}
func TestClientGet(t *testing.T) {
client, _ := NewClient("")
_, err := client.get("email", "john@gmail.com", "person", nil)
if err != nil {
t.Errorf("Client Get: %s", err.Error())
return
}
}