mirror of
https://github.com/prometheus/prometheus
synced 2024-12-24 23:42:32 +00:00
Add unit test case for func Type in record.go (#7082)
Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
This commit is contained in:
parent
c9565f08aa
commit
2393d6137b
@ -117,3 +117,26 @@ func TestRecord_Corrupted(t *testing.T) {
|
||||
testutil.Equals(t, err, encoding.ErrInvalidSize)
|
||||
})
|
||||
}
|
||||
|
||||
func TestRecord_Type(t *testing.T) {
|
||||
var enc Encoder
|
||||
var dec Decoder
|
||||
|
||||
series := []RefSeries{{Ref: 100, Labels: labels.FromStrings("abc", "123")}}
|
||||
recordType := dec.Type(enc.Series(series, nil))
|
||||
testutil.Equals(t, Series, recordType)
|
||||
|
||||
samples := []RefSample{{Ref: 123, T: 12345, V: 1.2345}}
|
||||
recordType = dec.Type(enc.Samples(samples, nil))
|
||||
testutil.Equals(t, Samples, recordType)
|
||||
|
||||
tstones := []tombstones.Stone{{Ref: 1, Intervals: tombstones.Intervals{{Mint: 1, Maxt: 2}}}}
|
||||
recordType = dec.Type(enc.Tombstones(tstones, nil))
|
||||
testutil.Equals(t, Tombstones, recordType)
|
||||
|
||||
recordType = dec.Type(nil)
|
||||
testutil.Equals(t, Invalid, recordType)
|
||||
|
||||
recordType = dec.Type([]byte{0})
|
||||
testutil.Equals(t, Invalid, recordType)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user