Sort fields in nowmetric test

This commit is contained in:
Daniel Nelson 2019-01-08 17:57:38 -08:00
parent bed90f1942
commit 10b3e45775
No known key found for this signature in database
GPG Key ID: CAAD59C9444F6155
1 changed files with 8 additions and 3 deletions

View File

@ -2,14 +2,14 @@ package nowmetric
import (
"fmt"
"sort"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/metric"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func MustMetric(v telegraf.Metric, err error) telegraf.Metric {
@ -136,6 +136,11 @@ func TestSerializeMultiFields(t *testing.T) {
m, err := metric.New("cpu", tags, fields, now)
assert.NoError(t, err)
// Sort for predictable field order
sort.Slice(m.FieldList(), func(i, j int) bool {
return m.FieldList()[i].Key < m.FieldList()[j].Key
})
s, _ := NewSerializer()
var buf []byte
buf, err = s.Serialize(m)