Throughout telegraf, use telegraf.Metric rather than client.Point
closes #599
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
"github.com/influxdata/telegraf/testutil"
|
||||
|
||||
"github.com/influxdata/influxdb/client/v2"
|
||||
"github.com/influxdata/telegraf"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -38,7 +38,7 @@ func TestUriOverride(t *testing.T) {
|
||||
d.Apikey = "123456"
|
||||
err := d.Connect()
|
||||
require.NoError(t, err)
|
||||
err = d.Write(testutil.MockBatchPoints().Points())
|
||||
err = d.Write(testutil.MockMetrics())
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ func TestBadStatusCode(t *testing.T) {
|
||||
d.Apikey = "123456"
|
||||
err := d.Connect()
|
||||
require.NoError(t, err)
|
||||
err = d.Write(testutil.MockBatchPoints().Points())
|
||||
err = d.Write(testutil.MockMetrics())
|
||||
if err == nil {
|
||||
t.Errorf("error expected but none returned")
|
||||
} else {
|
||||
@@ -100,12 +100,12 @@ func TestBuildTags(t *testing.T) {
|
||||
|
||||
func TestBuildPoint(t *testing.T) {
|
||||
var tagtests = []struct {
|
||||
ptIn *client.Point
|
||||
ptIn telegraf.Metric
|
||||
outPt Point
|
||||
err error
|
||||
}{
|
||||
{
|
||||
testutil.TestPoint(0.0, "test1"),
|
||||
testutil.TestMetric(0.0, "test1"),
|
||||
Point{
|
||||
float64(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC).Unix()),
|
||||
0.0,
|
||||
@@ -113,7 +113,7 @@ func TestBuildPoint(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
{
|
||||
testutil.TestPoint(1.0, "test2"),
|
||||
testutil.TestMetric(1.0, "test2"),
|
||||
Point{
|
||||
float64(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC).Unix()),
|
||||
1.0,
|
||||
@@ -121,7 +121,7 @@ func TestBuildPoint(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
{
|
||||
testutil.TestPoint(10, "test3"),
|
||||
testutil.TestMetric(10, "test3"),
|
||||
Point{
|
||||
float64(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC).Unix()),
|
||||
10.0,
|
||||
@@ -129,7 +129,7 @@ func TestBuildPoint(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
{
|
||||
testutil.TestPoint(int32(112345), "test4"),
|
||||
testutil.TestMetric(int32(112345), "test4"),
|
||||
Point{
|
||||
float64(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC).Unix()),
|
||||
112345.0,
|
||||
@@ -137,7 +137,7 @@ func TestBuildPoint(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
{
|
||||
testutil.TestPoint(int64(112345), "test5"),
|
||||
testutil.TestMetric(int64(112345), "test5"),
|
||||
Point{
|
||||
float64(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC).Unix()),
|
||||
112345.0,
|
||||
@@ -145,7 +145,7 @@ func TestBuildPoint(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
{
|
||||
testutil.TestPoint(float32(11234.5), "test6"),
|
||||
testutil.TestMetric(float32(11234.5), "test6"),
|
||||
Point{
|
||||
float64(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC).Unix()),
|
||||
11234.5,
|
||||
@@ -153,7 +153,7 @@ func TestBuildPoint(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
{
|
||||
testutil.TestPoint("11234.5", "test7"),
|
||||
testutil.TestMetric("11234.5", "test7"),
|
||||
Point{
|
||||
float64(time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC).Unix()),
|
||||
11234.5,
|
||||
@@ -162,7 +162,7 @@ func TestBuildPoint(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tagtests {
|
||||
pt, err := buildPoints(tt.ptIn)
|
||||
pt, err := buildMetrics(tt.ptIn)
|
||||
if err != nil && tt.err == nil {
|
||||
t.Errorf("%s: unexpected error, %+v\n", tt.ptIn.Name(), err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user