Add basic unittest for templating engine

This commit is contained in:
Daniel Nelson 2019-01-07 14:13:37 -08:00
parent 9800779e64
commit 3621bcf5a6
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
1 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,22 @@
package templating
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestEngineAlternateSeparator(t *testing.T) {
defaultTemplate, _ := NewDefaultTemplateWithPattern("topic*")
engine, err := NewEngine("_", defaultTemplate, []string{
"/ /*/*/* /measurement/origin/measurement*",
})
require.NoError(t, err)
name, tags, field, err := engine.Apply("/telegraf/host01/cpu")
require.NoError(t, err)
require.Equal(t, "telegraf_cpu", name)
require.Equal(t, map[string]string{
"origin": "host01",
}, tags)
require.Equal(t, "", field)
}