Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit ea90ab9

Browse files
committed
*DashboardByUid tests
1 parent 5ca3c23 commit ea90ab9

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

dashboard_test.go

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const (
1515
"version": 1
1616
}`
1717

18-
getDashboardBySlugResponse = `{
18+
getDashboardResponse = `{
1919
"dashboard": {
2020
"id": 1,
2121
"uid": "cIBgcSjkk",
@@ -62,32 +62,43 @@ func TestDashboardCreateAndUpdate(t *testing.T) {
6262
}
6363
}
6464

65-
func TestDashboardGetBySlug(t *testing.T) {
66-
server, client := gapiTestTools(200, getDashboardBySlugResponse)
65+
func TestDashboardGet(t *testing.T) {
66+
server, client := gapiTestTools(200, getDashboardResponse)
6767
defer server.Close()
6868

6969
resp, err := client.Dashboard("test")
7070
if err != nil {
7171
t.Error(err)
7272
}
73-
74-
t.Log(pretty.PrettyFormat(resp))
75-
7673
uid, ok := resp.Model["uid"]
7774
if !ok || uid != "cIBgcSjkk" {
7875
t.Errorf("Invalid uid - %s, Expected %s", uid, "cIBgcSjkk")
7976
}
8077

78+
resp, err = client.DashboardByUID("cIBgcSjkk")
79+
if err != nil {
80+
t.Error(err)
81+
}
82+
uid, ok = resp.Model["uid"]
83+
if !ok || uid != "cIBgcSjkk" {
84+
t.Errorf("Invalid uid - %s, Expected %s", uid, "cIBgcSjkk")
85+
}
86+
8187
for _, code := range []int{401, 403, 404} {
8288
server.code = code
8389
_, err = client.Dashboard("test")
8490
if err == nil {
8591
t.Errorf("%d not detected", code)
8692
}
93+
94+
_, err = client.DashboardByUID("cIBgcSjkk")
95+
if err == nil {
96+
t.Errorf("%d not detected", code)
97+
}
8798
}
8899
}
89100

90-
func TestDashboardDeleteBySlug(t *testing.T) {
101+
func TestDashboardDelete(t *testing.T) {
91102
server, client := gapiTestTools(200, "")
92103
defer server.Close()
93104

@@ -96,27 +107,22 @@ func TestDashboardDeleteBySlug(t *testing.T) {
96107
t.Error(err)
97108
}
98109

110+
err = client.DeleteDashboardByUID("cIBgcSjkk")
111+
if err != nil {
112+
t.Error(err)
113+
}
114+
99115
for _, code := range []int{401, 403, 404, 412} {
100116
server.code = code
117+
101118
err = client.DeleteDashboard("test")
102119
if err == nil {
103120
t.Errorf("%d not detected", code)
104121
}
122+
123+
err = client.DeleteDashboardByUID("cIBgcSjkk")
124+
if err == nil {
125+
t.Errorf("%d not detected", code)
126+
}
105127
}
106128
}
107-
108-
// func TestDashboardNew(t *testing.T) {
109-
// mock, client := newMockApiServer()
110-
// defer mock.server.Close()
111-
112-
// response, err := client.NewDashboard(exampleDashboard)
113-
// if err != nil {
114-
// t.Error(err)
115-
// }
116-
117-
// t.Log(pretty.PrettyFormat(response))
118-
119-
// if response.Uid == "" {
120-
// t.Error("dashboard creation response should return the created dashboard UID")
121-
// }
122-
// }

0 commit comments

Comments
 (0)