-
Notifications
You must be signed in to change notification settings - Fork 4
/
aircall_test.go
62 lines (55 loc) · 1.2 KB
/
aircall_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
package aircall
import (
"os"
"reflect"
"testing"
)
var (
testAppID = os.Getenv("AIRCALL_APP_ID")
testAppSecret = os.Getenv("AIRCALL_APP_SECRET")
testClient = NewClient(testAppID, testAppSecret)
expectedCompanyResponse = CompanyResponse{
Company{
Name: "TestCompany",
UsersCount: 1,
NumbersCount: 1,
},
}
expectedUsersResponse = UsersResponse{
Meta: ResponseMeta{
Count: 1,
Total: 1,
CurrentPage: 1,
PerPage: 20,
NextPageLink: "",
PreviousPageLink: "",
},
Users: []User{
User{
ID: 147262,
DirectLink: "https://api.aircall.io/v1/users/147262",
Name: "Test User",
Email: "[email protected]",
Available: true,
},
},
}
)
func TestApiPing(t *testing.T) {
res, err := testClient.Ping()
if err != nil {
t.Fatalf("Cannot call /ping endpoint [err: %v]", err)
}
if res.Ping != "pong" {
t.Error("Expected pong response")
}
}
func TestCompany(t *testing.T) {
res, err := testClient.Company()
if err != nil {
t.Fatalf("Cannot call /company endpoint [err: %v]", err)
}
if !reflect.DeepEqual(res, expectedCompanyResponse) {
t.Error("Invalid Company response")
}
}