-
Notifications
You must be signed in to change notification settings - Fork 0
/
explain_test.go
50 lines (43 loc) · 956 Bytes
/
explain_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
package influxqb
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
var testExplainBuilder = []struct {
d string
b BuilderIf
s string
e bool
}{
{
"Explain select",
NewExplainBuilder().
WithSelectBuilder(NewSelectBuilder().
Select("F1").
From("Toto").
Where(Eq(Field{Name: "totoField"}, 32))),
"EXPLAIN SELECT F1 FROM Toto WHERE (totoField = 32)",
false,
},
{
"Explain analyse select",
NewExplainBuilder().Analyze().
WithSelectBuilder(NewSelectBuilder().Select("F1").From("Toto").Where(Eq(Field{Name: "totoField"}, 32))),
"EXPLAIN ANALYZE SELECT F1 FROM Toto WHERE (totoField = 32)",
false,
},
}
func TestExplainBuilder(t *testing.T) {
for i, sample := range testExplainBuilder {
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]")
}
}