-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
access_test.go
73 lines (61 loc) · 1.98 KB
/
access_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
63
64
65
66
67
68
69
70
71
72
73
package gerrit_test
import (
"context"
"fmt"
"net/http"
"reflect"
"testing"
"github.com/andygrunwald/go-gerrit"
)
func TestAccessService_ListAccessRights(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/access/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, testValues{
"project": "go",
})
fmt.Fprint(w, `)]}'`+"\n"+`{"go":{"revision":"08f45ba74baef9699b650f42022df6467389c1f0","inherits_from":{"id":"All-Projects","name":"All-Projects","description":"Access inherited by all other projects.","state":"ACTIVE"},"local":{},"owner_of":[],"config_visible":false}}`)
})
opt := &gerrit.ListAccessRightsOptions{
Project: []string{"go"},
}
access, _, err := testClient.Access.ListAccessRights(context.Background(), opt)
if err != nil {
t.Errorf("Access.ListAccessRights returned error: %v", err)
}
want := &map[string]gerrit.ProjectAccessInfo{
"go": {
Revision: "08f45ba74baef9699b650f42022df6467389c1f0",
InheritsFrom: gerrit.ProjectInfo{
ID: "All-Projects",
Name: "All-Projects",
Parent: "",
Description: "Access inherited by all other projects.",
State: "ACTIVE",
},
Local: map[string]gerrit.AccessSectionInfo{},
OwnerOf: []string{},
ConfigVisible: false,
},
}
if !reflect.DeepEqual(access, want) {
t.Errorf("Access.ListAccessRights returned %+v, want %+v", access, want)
}
}
func TestAccessService_ListAccessRights_WithoutOpts(t *testing.T) {
setup()
defer teardown()
testMux.HandleFunc("/access/", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `)]}'`+"\n"+`{}`)
})
access, _, err := testClient.Access.ListAccessRights(context.Background(), nil)
if err != nil {
t.Errorf("Access.ListAccessRights returned error: %v", err)
}
want := &map[string]gerrit.ProjectAccessInfo{}
if !reflect.DeepEqual(access, want) {
t.Errorf("Access.ListAccessRights returned %+v, want %+v", access, want)
}
}