test(linters): Enable `testifylint`: `contains`, `encoded-compare` and `regexp` (#16262)
This commit is contained in:
parent
795b8a9f96
commit
2ccc79ce27
|
|
@ -335,7 +335,9 @@ linters-settings:
|
|||
- blank-import
|
||||
- bool-compare
|
||||
- compares
|
||||
- contains
|
||||
- empty
|
||||
- encoded-compare
|
||||
- error-is-as
|
||||
- error-nil
|
||||
- expected-actual
|
||||
|
|
@ -345,6 +347,7 @@ linters-settings:
|
|||
- len
|
||||
- negative-positive
|
||||
- nil-compare
|
||||
- regexp
|
||||
- require-error
|
||||
- suite-broken-parallel
|
||||
- suite-dont-use-pkg
|
||||
|
|
|
|||
|
|
@ -196,10 +196,10 @@ func TestSerializeBatch(t *testing.T) {
|
|||
require.NoError(t, s.Init())
|
||||
buf, err := s.SerializeBatch(metrics)
|
||||
require.NoError(t, err)
|
||||
require.Equal(
|
||||
require.JSONEq(
|
||||
t,
|
||||
[]byte(`{"metrics":[{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":0},{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":0}]}`+"\n"),
|
||||
buf,
|
||||
`{"metrics":[{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":0},{"fields":{"value":42},"name":"cpu","tags":{},"timestamp":0}]}`,
|
||||
string(buf),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ func TestSerializeBatchSkipInf(t *testing.T) {
|
|||
require.NoError(t, s.Init())
|
||||
buf, err := s.SerializeBatch(metrics)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte(`{"metrics":[{"fields":{"time_idle":42},"name":"cpu","tags":{},"timestamp":0}]}`+"\n"), buf)
|
||||
require.JSONEq(t, `{"metrics":[{"fields":{"time_idle":42},"name":"cpu","tags":{},"timestamp":0}]}`, string(buf))
|
||||
}
|
||||
|
||||
func TestSerializeBatchSkipInfAllFields(t *testing.T) {
|
||||
|
|
@ -239,7 +239,7 @@ func TestSerializeBatchSkipInfAllFields(t *testing.T) {
|
|||
require.NoError(t, s.Init())
|
||||
buf, err := s.SerializeBatch(metrics)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []byte(`{"metrics":[{"fields":{},"name":"cpu","tags":{},"timestamp":0}]}`+"\n"), buf)
|
||||
require.JSONEq(t, `{"metrics":[{"fields":{},"name":"cpu","tags":{},"timestamp":0}]}`, string(buf))
|
||||
}
|
||||
|
||||
func TestSerializeTransformationNonBatch(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -191,13 +191,11 @@ func TestSerializeBatch(t *testing.T) {
|
|||
s := &Serializer{}
|
||||
buf, err := s.SerializeBatch(metrics)
|
||||
require.NoError(t, err)
|
||||
require.Equal(
|
||||
require.JSONEq(
|
||||
t,
|
||||
[]byte(
|
||||
`[{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"},`+
|
||||
`{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"}]`,
|
||||
),
|
||||
buf,
|
||||
`[{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"},`+
|
||||
`{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"}]`,
|
||||
string(buf),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -213,10 +211,10 @@ func TestSerializeJSONv2Format(t *testing.T) {
|
|||
s := &Serializer{Format: "jsonv2"}
|
||||
buf, err := s.Serialize(m)
|
||||
require.NoError(t, err)
|
||||
require.Equal(
|
||||
require.JSONEq(
|
||||
t,
|
||||
[]byte(`{"records":[{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"}]}`),
|
||||
buf,
|
||||
`{"records":[{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"}]}`,
|
||||
string(buf),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -233,15 +231,13 @@ func TestSerializeJSONv2FormatBatch(t *testing.T) {
|
|||
metrics := []telegraf.Metric{m, m}
|
||||
buf, err := s.SerializeBatch(metrics)
|
||||
require.NoError(t, err)
|
||||
require.Equal(
|
||||
require.JSONEq(
|
||||
t,
|
||||
[]byte(
|
||||
`{"records":[`+
|
||||
`{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"},`+
|
||||
`{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"}`+
|
||||
`]}`,
|
||||
),
|
||||
buf,
|
||||
`{"records":[`+
|
||||
`{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"},`+
|
||||
`{"metric_type":"value","resource":"","node":"","value":42,"timestamp":0,"ci2metric_id":null,"source":"Telegraf"}`+
|
||||
`]}`,
|
||||
string(buf),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue