-
Notifications
You must be signed in to change notification settings - Fork 0
/
team_test.go
58 lines (44 loc) · 1.8 KB
/
team_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
package employmenthero
import (
"bytes"
"context"
"io/ioutil"
"net/http"
"testing"
"github.com/Thinkei/employmenthero-go/mocks"
"github.com/stretchr/testify/assert"
)
func TestListTeams(t *testing.T) {
r := ioutil.NopCloser(bytes.NewReader([]byte(`{"data":{"items":[{"id":"51c4b9c6-1ca5-4d72-8f75-6bb3a6xxxx", "name": "Developers", "status": "active"}],"item_per_page":20,"page_index":1,"total_pages":1,"total_items":1}}`)))
mocks.GetDoFunc = func(*http.Request) (*http.Response, error) {
return &http.Response{
StatusCode: 200,
Body: r,
}, nil
}
response, err := c.ListTeams(context.TODO(), "organisation_uid", ListParams{})
assert.Equal(t, response.Data.ItemPerPage, 20)
assert.Equal(t, response.Data.PageIndex, 1)
assert.Equal(t, response.Data.TotalItems, 1)
assert.Equal(t, response.Data.TotalPages, 1)
expectedResult := []Team{{Id: "51c4b9c6-1ca5-4d72-8f75-6bb3a6xxxx", Name: "Developers", Status: "active"}}
assert.Equal(t, response.Data.Items, expectedResult)
assert.Nil(t, err)
}
func TestListEmployeesByTeam(t *testing.T) {
r := ioutil.NopCloser(bytes.NewReader([]byte(`{"data":{"items":[{"id":"51c4b9c6-1ca5-4d72-8f75-6bb3a6xxxx"}],"item_per_page":20,"page_index":1,"total_pages":1,"total_items":1}}`)))
mocks.GetDoFunc = func(*http.Request) (*http.Response, error) {
return &http.Response{
StatusCode: 200,
Body: r,
}, nil
}
response, err := c.ListEmployeesByTeam(context.TODO(), "organisation_uid", "team_uid", ListParams{})
assert.Equal(t, response.Data.ItemPerPage, 20)
assert.Equal(t, response.Data.PageIndex, 1)
assert.Equal(t, response.Data.TotalItems, 1)
assert.Equal(t, response.Data.TotalPages, 1)
expectedResult := []Employee{{Id: "51c4b9c6-1ca5-4d72-8f75-6bb3a6xxxx"}}
assert.Equal(t, response.Data.Items, expectedResult)
assert.Nil(t, err)
}