Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed Dec 4, 2023
1 parent e9e3ab3 commit f7420a3
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions expfmt/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package expfmt
import (
"bufio"
"io"
"math"
"net/http"
"reflect"
"sort"
Expand Down Expand Up @@ -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: "",
Expand Down Expand Up @@ -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,
},
},
},
}

Expand All @@ -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,
},
Expand Down

0 comments on commit f7420a3

Please sign in to comment.