1
0
mirror of https://github.com/Oxalide/vsphere-influxdb-go.git synced 2023-10-10 13:36:51 +02:00
vsphere-influxdb-go/vendor/github.com/influxdata/influxdb/stress/v2/statement/template_test.go
2017-10-25 20:52:40 +00:00

73 lines
1.4 KiB
Go

package statement
import (
"testing"
)
func TestNewTagFunc(t *testing.T) {
wtags := newTestTagsTemplate()
wfunc := newTestFunctionTemplate()
expected := wtags.Tags[0]
got := wtags.NewTagFunc()()
if got != expected {
t.Errorf("expected: %v\ngot: %v\n", expected, got)
}
expected = "EMPTY TAGS"
got = wfunc.NewTagFunc()()
if got != expected {
t.Errorf("expected: %v\ngot: %v\n", expected, got)
}
}
func TestNumSeries(t *testing.T) {
wtags := newTestTagsTemplate()
wfunc := newTestFunctionTemplate()
expected := len(wtags.Tags)
got := wtags.numSeries()
if got != expected {
t.Errorf("expected: %v\ngot: %v\n", expected, got)
}
expected = wfunc.Function.Count
got = wfunc.numSeries()
if got != expected {
t.Errorf("expected: %v\ngot: %v\n", expected, got)
}
}
func TestTemplatesInit(t *testing.T) {
tmpls := newTestTemplates()
s := tmpls.Init(5)
vals := s.Eval(spoofTime)
expected := tmpls[0].Tags[0]
got := vals[0]
if got != expected {
t.Errorf("expected: %v\ngot: %v\n", expected, got)
}
expected = "0i"
got = vals[1]
if got != expected {
t.Errorf("expected: %v\ngot: %v\n", expected, got)
}
}
func newTestTemplates() Templates {
return []*Template{
newTestTagsTemplate(),
newTestFunctionTemplate(),
}
}
func newTestTagsTemplate() *Template {
return &Template{
Tags: []string{"thing", "other_thing"},
}
}
func newTestFunctionTemplate() *Template {
return &Template{
Function: newIntIncFunction(),
}
}