Add unit tests for the root telegraf package

This commit is contained in:
Cameron Sparr
2016-01-29 14:58:38 -07:00
parent 338341add8
commit 38c4111e6c
3 changed files with 150 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
package telegraf
import (
"bytes"
"time"
"github.com/influxdata/influxdb/client/v2"
@@ -68,6 +69,8 @@ func NewMetric(
// a non-nil error will be returned in addition to the metrics that parsed
// successfully.
func ParseMetrics(buf []byte) ([]Metric, error) {
// parse even if the buffer begins with a newline
buf = bytes.TrimPrefix(buf, []byte("\n"))
points, err := models.ParsePoints(buf)
metrics := make([]Metric, len(points))
for i, point := range points {