Skip to content

Commit 757132b

Browse files
glintondanielnelson
authored andcommitted
Add test for include/exclude filter (influxdata#5193)
1 parent acd176c commit 757132b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

filter/filter_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ func TestCompile(t *testing.T) {
3737
assert.True(t, f.Match("network"))
3838
}
3939

40+
func TestIncludeExclude(t *testing.T) {
41+
tags := []string{}
42+
labels := []string{"best", "com_influxdata", "timeseries", "com_influxdata_telegraf", "ever"}
43+
44+
filter, err := NewIncludeExcludeFilter([]string{}, []string{"com_influx*"})
45+
if err != nil {
46+
t.Fatalf("Failed to create include/exclude filter - %v", err)
47+
}
48+
49+
for i := range labels {
50+
if filter.Match(labels[i]) {
51+
tags = append(tags, labels[i])
52+
}
53+
}
54+
55+
assert.Equal(t, []string{"best", "timeseries", "ever"}, tags)
56+
}
57+
4058
var benchbool bool
4159

4260
func BenchmarkFilterSingleNoGlobFalse(b *testing.B) {

0 commit comments

Comments
 (0)