-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_a_directory_of_employees_test.go
48 lines (41 loc) · 1.17 KB
/
get_a_directory_of_employees_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
package bamboohr_test
import (
"fmt"
"net/http"
"testing"
"gotest.tools/assert"
bamboohr "github.com/AkihikoITOH/bamboohr.go"
)
var employeeDirectoryData = []byte(
`{
"employees": [
{
"id": "99999",
"firstName": "John",
"lastName": "Doe"
}
]
}`)
func Example_getADirectoryOfEmployees() {
conf := bamboohr.NewConfig("api-domain", "api-key")
api := bamboohr.NewAPI(conf)
api.GetADirectoryOfEmployees()
}
func TestGetADirectoryOfEmployees(t *testing.T) {
client := NewMockClient(employeeDirectoryData)
api := &bamboohr.API{Config: mockAPIConfig, HTTPClient: client}
employees, err := api.GetADirectoryOfEmployees()
if err != nil {
fmt.Println(err.Error())
return
}
// Check request object
assert.Equal(t, client.Request.Method, http.MethodGet)
assert.Equal(t, client.Request.URL.String(), "https://api.bamboohr.com/api/gateway.php/test/v1/employees/directory")
assert.Equal(t, client.Request.Body, nil)
SharedRequestTests(t, client.Request)
// Check employee object
assert.Equal(t, employees.Employees[0].ID, 99999)
assert.Equal(t, employees.Employees[0].FirstName, "John")
assert.Equal(t, employees.Employees[0].LastName, "Doe")
}