forked from xanzy/go-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings_test.go
51 lines (42 loc) · 1.2 KB
/
settings_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
package gitlab
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestGetSettings(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/api/v4/application/settings", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"id":1, "default_projects_limit" : 100000}`)
})
settings, _, err := client.Settings.GetSettings()
if err != nil {
t.Fatal(err)
}
want := &Settings{ID: 1, DefaultProjectsLimit: 100000}
if !reflect.DeepEqual(settings, want) {
t.Errorf("Settings.GetSettings returned %+v, want %+v", settings, want)
}
}
func TestUpdateSettings(t *testing.T) {
mux, server, client := setup()
defer teardown(server)
mux.HandleFunc("/api/v4/application/settings", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PUT")
fmt.Fprint(w, `{"default_projects_limit" : 100}`)
})
options := &UpdateSettingsOptions{
DefaultProjectsLimit: Int(100),
}
settings, _, err := client.Settings.UpdateSettings(options)
if err != nil {
t.Fatal(err)
}
want := &Settings{DefaultProjectsLimit: 100}
if !reflect.DeepEqual(settings, want) {
t.Errorf("Settings.UpdateSettings returned %+v, want %+v", settings, want)
}
}