-
Notifications
You must be signed in to change notification settings - Fork 0
/
drop_series_test.go
77 lines (67 loc) · 1.34 KB
/
drop_series_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package influxqb
import (
"fmt"
"github.com/influxdata/influxql"
"github.com/stretchr/testify/assert"
"regexp"
"testing"
)
/*
*/
var testDropSeriesBuilder = []struct {
d string
b BuilderIf
s string
e bool
}{
{"Drop Series from ",
NewDropSeries().
From(NewMeasurement().Name("M")),
"DROP SERIES FROM M",
false,
},
{"Drop Series from ",
NewDropSeries().From(
NewMeasurement().
Name("M").
WithDatabase("db").
WithPolicy("policy1"),
),
"DROP SERIES FROM db.policy1.M",
false,
},
{"Drop Series from Where",
NewDropSeries().
From(NewMeasurement().Regex(regexp.MustCompile(".*"))).
Where(Eq(&Field{Name: "cpu"}, "cpu2")),
"DROP SERIES FROM /.*/ WHERE (cpu = 'cpu2')",
false,
},
{"Drop series where ",
NewDropSeries().
Where(Eq(&Field{Name: "cpu"}, "cpu2")),
"DROP SERIES WHERE (cpu = 'cpu2')",
false,
},
{"Drop Series MathExpr",
NewDropSeries().
Where(&Math{Expr: []interface{}{
&Field{Name: "cpu"}, influxql.EQ, "cpu2"}},
),
"DROP SERIES WHERE (cpu = 'cpu2')",
false,
},
}
func TestDropSeriesBuilder(t *testing.T) {
for i, sample := range testDropSeriesBuilder {
s, err := sample.b.Build()
fmt.Print("Test ", i, ": ", sample.d)
if sample.e {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
assert.Equal(t, sample.s, s)
fmt.Println(" [OK]")
}
}