-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_continuous_query_test.go
48 lines (41 loc) · 1.23 KB
/
create_continuous_query_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
package influxqb
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
var testCreateContinuousQueryBuilder = []struct {
d string
b BuilderIf
s string
e bool
}{
{
"Simple Continuous Query ",
NewCreateContinuousQueryBuilder().WithName("ContinuousQuery").WithDatabase("db").
WithResamplingIntervalFromString("12h").WithTimeoutString("1h"),
"CREATE CONTINUOUS QUERY ContinuousQuery ON db RESAMPLE EVERY 12h FOR 1h BEGIN SELECT END",
false,
},
{
"Simple Continuous Query with select builder ",
NewCreateContinuousQueryBuilder().WithName("ContinuousQuery").WithDatabase("db").
WithResamplingIntervalFromString("12h").WithTimeoutString("1h").
WithSelectBuilder(NewSelectBuilder().Select("F1").From("Toto").Where(Eq(Field{Name: "totoField"}, 32))),
"CREATE CONTINUOUS QUERY ContinuousQuery ON db RESAMPLE EVERY 12h FOR 1h BEGIN SELECT F1 FROM Toto WHERE (totoField = 32) END",
false,
},
}
func TestCreateContinuousQueryBuilder(t *testing.T) {
for i, sample := range testCreateContinuousQueryBuilder {
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]")
}
}