forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 2
/
s2geo_test.go
55 lines (47 loc) · 982 Bytes
/
s2geo_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
51
52
53
54
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)
}