MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestPreallocTimeseriesSliceFromPool

Function TestPreallocTimeseriesSliceFromPool

pkg/cortexpb/timeseries_test.go:32–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestPreallocTimeseriesSliceFromPool(t *testing.T) {
33 t.Run("new instance is provided when not available to reuse", func(t *testing.T) {
34 first := PreallocTimeseriesSliceFromPool()
35 second := PreallocTimeseriesSliceFromPool()
36
37 assert.NotSame(t, &first, &second)
38 })
39
40 t.Run("instance is cleaned before reusing", func(t *testing.T) {
41 slice := PreallocTimeseriesSliceFromPool()
42 slice = append(slice, PreallocTimeseries{TimeSeries: &TimeSeries{}})
43 ReuseSlice(slice)
44
45 reused := PreallocTimeseriesSliceFromPool()
46 assert.Len(t, reused, 0)
47 })
48}
49
50func TestTimeseriesFromPool(t *testing.T) {
51 t.Run("new instance is provided when not available to reuse", func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

ReuseSliceFunction · 0.85
RunMethod · 0.65
LenMethod · 0.45

Tested by

no test coverage detected