-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmembers_test.go
43 lines (34 loc) · 945 Bytes
/
members_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
package asana
import (
"net/http"
"testing"
"github.com/h2non/gock"
)
type o map[string]any
func TestProject_Memberships(t *testing.T) {
defer gock.Off()
gock.New("https://app.asana.com").
Get("/api/1.0/memberships").
Reply(200).
JSON(o{"data": []o{{
"gid": "12345",
"resource_type": "team",
"parent": o{"gid": "63627", "resource_type": "project", "name": "test"},
"member": o{"gid": "12345", "resource_type": "team", "name": "team1"},
"access_level": "admin",
"resource_subtype": "project_membership",
}}})
project := &Project{}
client := NewClient(http.DefaultClient)
memberships, _, err := project.Memberships(client)
if err != nil {
t.Error(err)
}
if len(memberships) != 1 {
t.Errorf("Expected 1 membership but found %d", len(memberships))
}
m := memberships[0]
if m.ID != "12345" {
t.Errorf("Expected membership ID 12345 but saw %s", m.ID)
}
}