2015-02-20 23:59:02 +00:00
|
|
|
package influxdb_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/influxdb/influxdb"
|
|
|
|
)
|
|
|
|
|
2015-02-21 00:25:27 +00:00
|
|
|
// Ensure that data with epoch timestamps can be decoded.
|
2015-02-20 23:59:02 +00:00
|
|
|
func TestBatchPoints_Normal(t *testing.T) {
|
|
|
|
var p influxdb.BatchPoints
|
|
|
|
data := []byte(`
|
|
|
|
{
|
|
|
|
"database": "foo",
|
|
|
|
"retentionPolicy": "bar",
|
|
|
|
"points": [
|
|
|
|
{
|
|
|
|
"name": "cpu",
|
|
|
|
"tags": {
|
|
|
|
"host": "server01"
|
|
|
|
},
|
|
|
|
"timestamp": 14244733039069373,
|
|
|
|
"precision": "n",
|
2015-02-21 00:25:27 +00:00
|
|
|
"values": {
|
2015-02-20 23:59:02 +00:00
|
|
|
"value": 4541770385657154000
|
2015-02-21 00:25:27 +00:00
|
|
|
}
|
2015-02-20 23:59:02 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "cpu",
|
|
|
|
"tags": {
|
|
|
|
"host": "server01"
|
|
|
|
},
|
|
|
|
"timestamp": 14244733039069380,
|
|
|
|
"precision": "n",
|
2015-02-21 00:25:27 +00:00
|
|
|
"values": {
|
2015-02-20 23:59:02 +00:00
|
|
|
"value": 7199311900554737000
|
2015-02-21 00:25:27 +00:00
|
|
|
}
|
2015-02-20 23:59:02 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`)
|
|
|
|
|
|
|
|
if err := json.Unmarshal(data, &p); err != nil {
|
2015-02-21 00:25:27 +00:00
|
|
|
t.Errorf("failed to unmarshal nanosecond data: %s", err.Error())
|
2015-02-20 23:59:02 +00:00
|
|
|
}
|
|
|
|
}
|