|
@@ -78,7 +78,31 @@ func TestAnnotations(t *testing.T) {
|
|
|
So(err, ShouldBeNil)
|
|
So(err, ShouldBeNil)
|
|
|
So(annotation2.Id, ShouldBeGreaterThan, 0)
|
|
So(annotation2.Id, ShouldBeGreaterThan, 0)
|
|
|
|
|
|
|
|
- Convey("Can query for annotation", func() {
|
|
|
|
|
|
|
+ globalAnnotation1 := &annotations.Item{
|
|
|
|
|
+ OrgId: 1,
|
|
|
|
|
+ UserId: 1,
|
|
|
|
|
+ Text: "deploy",
|
|
|
|
|
+ Type: "",
|
|
|
|
|
+ Epoch: 15,
|
|
|
|
|
+ Tags: []string{"deploy"},
|
|
|
|
|
+ }
|
|
|
|
|
+ err = repo.Save(globalAnnotation1)
|
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
|
+ So(globalAnnotation1.Id, ShouldBeGreaterThan, 0)
|
|
|
|
|
+
|
|
|
|
|
+ globalAnnotation2 := &annotations.Item{
|
|
|
|
|
+ OrgId: 1,
|
|
|
|
|
+ UserId: 1,
|
|
|
|
|
+ Text: "rollback",
|
|
|
|
|
+ Type: "",
|
|
|
|
|
+ Epoch: 17,
|
|
|
|
|
+ Tags: []string{"rollback"},
|
|
|
|
|
+ }
|
|
|
|
|
+ err = repo.Save(globalAnnotation2)
|
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
|
+ So(globalAnnotation2.Id, ShouldBeGreaterThan, 0)
|
|
|
|
|
+
|
|
|
|
|
+ Convey("Can query for annotation by dashboard id", func() {
|
|
|
items, err := repo.Find(&annotations.ItemQuery{
|
|
items, err := repo.Find(&annotations.ItemQuery{
|
|
|
OrgId: 1,
|
|
OrgId: 1,
|
|
|
DashboardId: 1,
|
|
DashboardId: 1,
|
|
@@ -165,7 +189,7 @@ func TestAnnotations(t *testing.T) {
|
|
|
OrgId: 1,
|
|
OrgId: 1,
|
|
|
DashboardId: 1,
|
|
DashboardId: 1,
|
|
|
From: 1,
|
|
From: 1,
|
|
|
- To: 15,
|
|
|
|
|
|
|
+ To: 15, //this will exclude the second test annotation
|
|
|
Tags: []string{"outage", "error"},
|
|
Tags: []string{"outage", "error"},
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -173,6 +197,19 @@ func TestAnnotations(t *testing.T) {
|
|
|
So(items, ShouldHaveLength, 1)
|
|
So(items, ShouldHaveLength, 1)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ Convey("Should find two annotations using partial match", func() {
|
|
|
|
|
+ items, err := repo.Find(&annotations.ItemQuery{
|
|
|
|
|
+ OrgId: 1,
|
|
|
|
|
+ From: 1,
|
|
|
|
|
+ To: 25,
|
|
|
|
|
+ MatchAny: true,
|
|
|
|
|
+ Tags: []string{"rollback", "deploy"},
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
|
+ So(items, ShouldHaveLength, 2)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
Convey("Should find one when all key value tag filters does match", func() {
|
|
Convey("Should find one when all key value tag filters does match", func() {
|
|
|
items, err := repo.Find(&annotations.ItemQuery{
|
|
items, err := repo.Find(&annotations.ItemQuery{
|
|
|
OrgId: 1,
|
|
OrgId: 1,
|