From f7420a3df333429d34a44488bfad2d4ab23129f4 Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Mon, 4 Dec 2023 10:31:46 -0500 Subject: [PATCH] fix test --- expfmt/decode_test.go | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/expfmt/decode_test.go b/expfmt/decode_test.go index f092b588..5e63cdef 100644 --- a/expfmt/decode_test.go +++ b/expfmt/decode_test.go @@ -16,6 +16,7 @@ package expfmt import ( "bufio" "io" + "math" "net/http" "reflect" "sort" @@ -104,10 +105,10 @@ func TestProtoDecoder(t *testing.T) { var testTime = model.Now() scenarios := []struct { - in string - expected model.Vector + in string + expected model.Vector legacyNameFail bool - fail bool + fail bool }{ { in: "", @@ -334,8 +335,28 @@ func TestProtoDecoder(t *testing.T) { }, }, { - in: "\xa8\x01\n\ngauge.name\x12\x11gauge\ndoc\nstr\"ing\x18\x01\"T\n\x1b\n\x06name.1\x12\x11val with\nnew line\n*\n\x06name*2\x12 val with \\backslash and \"quotes\"\x12\t\t\x00\x00\x00\x00\x00\x00\xf0\x7f\"/\n\x10\n\x06name.1\x12\x06Björn\n\x10\n\x06name*2\x12\x06佖佥\x12\t\t\xd1\xcfD\xb9\xd0\x05\xc2H", + in: "\xa8\x01\n\ngauge.name\x12\x11gauge\ndoc\nstr\"ing\x18\x01\"T\n\x1b\n\x06name.1\x12\x11val with\nnew line\n*\n\x06name*2\x12 val with \\backslash and \"quotes\"\x12\t\t\x00\x00\x00\x00\x00\x00\xf0\x7f\"/\n\x10\n\x06name.1\x12\x06Björn\n\x10\n\x06name*2\x12\x06佖佥\x12\t\t\xd1\xcfD\xb9\xd0\x05\xc2H", legacyNameFail: true, + expected: model.Vector{ + &model.Sample{ + Metric: model.Metric{ + model.MetricNameLabel: "gauge.name", + "name.1": "val with\nnew line", + "name*2": "val with \\backslash and \"quotes\"", + }, + Value: model.SampleValue(math.Inf(+1)), + Timestamp: testTime, + }, + &model.Sample{ + Metric: model.Metric{ + model.MetricNameLabel: "gauge.name", + "name.1": "Björn", + "name*2": "佖佥", + }, + Value: 3.14e42, + Timestamp: testTime, + }, + }, }, } @@ -360,9 +381,9 @@ func TestProtoDecoder(t *testing.T) { } dec := &SampleDecoder{ Dec: &protoDecoder{ - r: strings.NewReader(scenario.in), + r: strings.NewReader(scenario.in), utf8Names: true, - }, + }, Opts: &DecodeOptions{ Timestamp: testTime, },