Browse Source

stackdriver: test build filter string

Erik Sundell 7 năm trước cách đây
mục cha
commit
a3122a4b85
1 tập tin đã thay đổi với 13 bổ sung0 xóa
  1. 13 0
      pkg/tsdb/stackdriver/stackdriver_test.go

+ 13 - 0
pkg/tsdb/stackdriver/stackdriver_test.go

@@ -405,6 +405,19 @@ func TestStackdriver(t *testing.T) {
 			})
 		})
 
+		Convey("when building filter string", func() {
+			Convey("and there are wildcards in a filter value", func() {
+				filterParts := []interface{}{"zone", "=", "*-central1*"}
+				value := buildFilterString("somemetrictype", filterParts)
+				So(value, ShouldEqual, `metric.type="somemetrictype" zone=has_substring("-central1")`)
+			})
+
+			Convey("and there are no wildcards in any filter value", func() {
+				filterParts := []interface{}{"zone", "=", "us-central1-a"}
+				value := buildFilterString("somemetrictype", filterParts)
+				So(value, ShouldEqual, `metric.type="somemetrictype" zone="us-central1-a"`)
+			})
+		})
 	})
 }