Skip to content

Commit

Permalink
Sort fields in nowmetric test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson authored and Jean-Louis Dupond committed Apr 22, 2019
1 parent 70a2e42 commit b60de6b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/serializers/nowmetric/nowmetric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b60de6b

Please sign in to comment.