forked from grafana/grafana-api-golang-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
folder_dashboard_search_test.go
62 lines (58 loc) · 1.39 KB
/
folder_dashboard_search_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
package gapi
import (
"testing"
)
const (
// This response is copied from the examples in the API docs:
// https://grafana.com/docs/grafana/latest/http_api/folder_dashboard_search/
getFolderDashboardSearchResponse = `[
{
"id": 163,
"uid": "000000163",
"title": "Folder",
"url": "/dashboards/f/000000163/folder",
"type": "dash-folder",
"tags": [],
"isStarred": false,
"uri":"db/folder"
},
{
"id":1,
"uid": "cIBgcSjkk",
"title":"Production Overview",
"url": "/d/cIBgcSjkk/production-overview",
"type":"dash-db",
"tags":["prod"],
"isStarred":true,
"uri":"db/production-overview"
},
{
"id":1,
"uid": "cIBgcSjkk",
"title":"Production Overview",
"url": "/d/cIBgcSjkk/production-overview",
"type":"dash-db",
"tags":["prod"],
"isStarred":true,
"folderId": 2,
"folderUid": "000000163",
"folderTitle": "Folder",
"folderUrl": "/dashboards/f/000000163/folder",
"uri":"db/production-overview"
}
]`
)
func TestFolderDashboardSearch(t *testing.T) {
server, client := gapiTestTools(t, 200, getFolderDashboardSearchResponse)
defer server.Close()
resp, err := client.FolderDashboardSearch(map[string]string{})
if err != nil {
t.Fatal(err)
}
if len(resp) != 3 {
t.Errorf("Expected 3 objects in response, got %d", len(resp))
}
if resp[0].ID != 163 || resp[0].Title != "Folder" {
t.Error("Not correctly parsing response.")
}
}