forked from grafana/grafana-api-golang-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
org_preferences_test.go
56 lines (45 loc) · 1.3 KB
/
org_preferences_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
package gapi
import (
"testing"
)
const (
getOrgPreferencesJSON = `{"theme": "foo","homeDashboardId": 0,"timezone": "","weekStart": "","navbar": {"savedItems": null},"queryHistory": {"homeTab": ""}}`
updateOrgPreferencesJSON = `{"message":"Preferences updated"}`
)
func TestOrgPreferences(t *testing.T) {
client := gapiTestTools(t, 200, getOrgPreferencesJSON)
resp, err := client.OrgPreferences()
if err != nil {
t.Fatal(err)
}
expected := "foo"
if resp.Theme != expected {
t.Errorf("Expected org preferences theme '%s'; got '%s'", expected, resp.Theme)
}
}
func TestUpdateOrgPreferences(t *testing.T) {
client := gapiTestTools(t, 200, updateOrgPreferencesJSON)
resp, err := client.UpdateOrgPreferences(Preferences{
Theme: "foo",
})
if err != nil {
t.Fatal(err)
}
expected := "Preferences updated"
if resp.Message != expected {
t.Errorf("Expected org preferences message '%s'; got '%s'", expected, resp.Message)
}
}
func TestUpdateAllOrgPreference(t *testing.T) {
client := gapiTestTools(t, 200, updateOrgPreferencesJSON)
resp, err := client.UpdateAllOrgPreferences(Preferences{
Theme: "foo",
})
if err != nil {
t.Fatal(err)
}
expected := "Preferences updated"
if resp.Message != expected {
t.Errorf("Expected org preferences message '%s'; got '%s'", expected, resp.Message)
}
}