Fix s2geo documentation and code to reflect current plugin name

This commit is contained in:
Daniel Nelson
2020-03-18 12:28:02 -07:00
parent ffaa9467a5
commit 35ef2559d3
5 changed files with 17 additions and 14 deletions

View File

@@ -0,0 +1,55 @@
package geo
import (
"testing"
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/testutil"
"github.com/stretchr/testify/require"
)
func TestGeo(t *testing.T) {
plugin := &Geo{
LatField: "lat",
LonField: "lon",
TagKey: "s2_cell_id",
CellLevel: 11,
}
pluginMostlyDefault := &Geo{
CellLevel: 11,
}
err := plugin.Init()
require.NoError(t, err)
metric := testutil.MustMetric(
"mta",
map[string]string{},
map[string]interface{}{
"lat": 40.878738,
"lon": -72.517572,
},
time.Unix(1578603600, 0),
)
expected := []telegraf.Metric{
testutil.MustMetric(
"mta",
map[string]string{
"s2_cell_id": "89e8ed4",
},
map[string]interface{}{
"lat": 40.878738,
"lon": -72.517572,
},
time.Unix(1578603600, 0),
),
}
actual := plugin.Apply(metric)
testutil.RequireMetricsEqual(t, expected, actual)
actual = pluginMostlyDefault.Apply(metric)
testutil.RequireMetricsEqual(t, expected, actual)
}