added more UNIT test cases for covering all parts of the code
added debug statement for debugging OpenTSDB communication Closes #182
This commit is contained in:
committed by
Cameron Sparr
parent
fc41cc9878
commit
9a0c0886ce
@@ -3,7 +3,9 @@ package opentsdb
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/influxdb/influxdb/client"
|
||||
"github.com/influxdb/telegraf/testutil"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
@@ -60,4 +62,34 @@ func TestWrite(t *testing.T) {
|
||||
// Verify that we can successfully write data to OpenTSDB
|
||||
err = o.Write(testutil.MockBatchPoints())
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify postive and negative test cases of writing data
|
||||
var bp client.BatchPoints
|
||||
bp.Time = time.Now()
|
||||
bp.Tags = map[string]string{"testkey": "testvalue"}
|
||||
bp.Points = []client.Point{
|
||||
{
|
||||
Measurement: "justametric.float",
|
||||
Fields: map[string]interface{}{"value": float64(1.0)},
|
||||
},
|
||||
{
|
||||
Measurement: "justametric.int",
|
||||
Fields: map[string]interface{}{"value": int64(123456789)},
|
||||
},
|
||||
{
|
||||
Measurement: "justametric.uint",
|
||||
Fields: map[string]interface{}{"value": uint64(123456789012345)},
|
||||
},
|
||||
{
|
||||
Measurement: "justametric.string",
|
||||
Fields: map[string]interface{}{"value": "Lorem Ipsum"},
|
||||
},
|
||||
{
|
||||
Measurement: "justametric.anotherfloat",
|
||||
Fields: map[string]interface{}{"value": float64(42.0)},
|
||||
},
|
||||
}
|
||||
err = o.Write(bp)
|
||||
require.NoError(t, err)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user