Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix carbon2 tests #8254

Merged
merged 2 commits into from
Dec 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions plugins/serializers/carbon2/carbon2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,34 +228,34 @@ func TestSerializeMetricBool(t *testing.T) {

testcases := []struct {
metric telegraf.Metric
format string
format format
expected string
}{
{
metric: requireMetric(t, now, false),
format: string(Carbon2FormatFieldSeparate),
format: Carbon2FormatFieldSeparate,
expected: fmt.Sprintf("metric=cpu field=java_lang_GarbageCollector_Valid tag_name=tag_value 0 %d\n", now.Unix()),
},
{
metric: requireMetric(t, now, false),
format: string(Carbon2FormatMetricIncludesField),
format: Carbon2FormatMetricIncludesField,
expected: fmt.Sprintf("metric=cpu_java_lang_GarbageCollector_Valid tag_name=tag_value 0 %d\n", now.Unix()),
},
{
metric: requireMetric(t, now, true),
format: string(Carbon2FormatFieldSeparate),
format: Carbon2FormatFieldSeparate,
expected: fmt.Sprintf("metric=cpu field=java_lang_GarbageCollector_Valid tag_name=tag_value 1 %d\n", now.Unix()),
},
{
metric: requireMetric(t, now, true),
format: string(Carbon2FormatMetricIncludesField),
format: Carbon2FormatMetricIncludesField,
expected: fmt.Sprintf("metric=cpu_java_lang_GarbageCollector_Valid tag_name=tag_value 1 %d\n", now.Unix()),
},
}

for _, tc := range testcases {
t.Run(tc.format, func(t *testing.T) {
s, err := NewSerializer(tc.format)
t.Run(string(tc.format), func(t *testing.T) {
s, err := NewSerializer(string(tc.format))
require.NoError(t, err)

buf, err := s.Serialize(tc.metric)
Expand Down