Sort fields in nowmetric test
This commit is contained in:
parent
bed90f1942
commit
10b3e45775
|
@ -2,14 +2,14 @@ package nowmetric
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
|
|
||||||
"github.com/influxdata/telegraf"
|
"github.com/influxdata/telegraf"
|
||||||
"github.com/influxdata/telegraf/metric"
|
"github.com/influxdata/telegraf/metric"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MustMetric(v telegraf.Metric, err error) telegraf.Metric {
|
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)
|
m, err := metric.New("cpu", tags, fields, now)
|
||||||
assert.NoError(t, err)
|
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()
|
s, _ := NewSerializer()
|
||||||
var buf []byte
|
var buf []byte
|
||||||
buf, err = s.Serialize(m)
|
buf, err = s.Serialize(m)
|
||||||
|
|
Loading…
Reference in New Issue