forked from grafana-tools/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrest-annotation_test.go
47 lines (39 loc) · 945 Bytes
/
rest-annotation_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
package sdk_test
import (
"net/http"
"testing"
"github.com/grafana-tools/sdk"
)
func TestAnnotationOptions(t *testing.T) {
request, _ := http.NewRequest("GET", "", nil)
params := []sdk.GetAnnotationsParams{
sdk.WithTag("foo"),
sdk.WithTag("bar"),
sdk.WithLimit(3),
sdk.WithAnnotationType(),
sdk.WithDashboard(1),
}
for _, p := range params {
p(request)
}
v := request.URL.Query()
l := v.Get("limit")
if l != "3" {
t.Errorf("expected limit to be %s, but was %s", "3", l)
}
tags := v["tags"]
if len(tags) != 2 {
t.Errorf("expected length of tags to be %d, but was %d", 2, len(tags))
}
if tags[1] != "bar" {
t.Errorf("expected last tag to be %s, but was %s", "bar", tags[1])
}
tp := v.Get("type")
if tp != "annotation" {
t.Errorf("expected type to be %s, but was %s", "annotation", tp)
}
id := v.Get("dashboardId")
if id != "1" {
t.Errorf("expected dashboard to be %s, but was %s", "1", id)
}
}