| 1 |
package statement |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/influxdata/influxdb/stress/v2/stress_client" |
| 7 |
) |
| 8 |
|
| 9 |
func TestQuerySetID(t *testing.T) { |
| 10 |
e := newTestQuery() |
| 11 |
newID := "oaijnifo" |
| 12 |
e.SetID(newID) |
| 13 |
if e.StatementID != newID { |
| 14 |
t.Errorf("Expected: %v\nGot: %v\n", newID, e.StatementID) |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
func TestQueryRun(t *testing.T) { |
| 19 |
i := newTestQuery() |
| 20 |
s, packageCh, _ := stressClient.NewTestStressTest() |
| 21 |
|
| 22 |
go func() { |
| 23 |
for pkg := range packageCh { |
| 24 |
if i.TemplateString != string(pkg.Body) { |
| 25 |
t.Fail() |
| 26 |
} |
| 27 |
pkg.Tracer.Done() |
| 28 |
} |
| 29 |
}() |
| 30 |
i.Run(s) |
| 31 |
} |
| 32 |
|
| 33 |
func newTestQuery() *QueryStatement { |
| 34 |
return &QueryStatement{ |
| 35 |
StatementID: "foo_ID", |
| 36 |
Name: "foo_name", |
| 37 |
TemplateString: "SELECT count(value) FROM cpu", |
| 38 |
Args: []string{}, |
| 39 |
Count: 5, |
| 40 |
Tracer: stressClient.NewTracer(map[string]string{}), |
| 41 |
} |
| 42 |
} |