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

Function TestStats_Copy

pkg/querier/stats/stats_test.go:11–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestStats_Copy(t *testing.T) {
12 t.Run("stats is nil", func(t *testing.T) {
13 var stats *QueryStats
14 copied := stats.Copy()
15 assert.Nil(t, copied)
16 })
17 t.Run("stats is not nil", func(t *testing.T) {
18 stats, _ := ContextWithEmptyStats(context.Background())
19 stats.AddWallTime(time.Second)
20 copied := stats.Copy()
21
22 // value should be the same
23 assert.Equal(t, time.Second, copied.LoadWallTime())
24 p1, p2 := &copied, &stats
25
26 // address should be different
27 assert.False(t, p1 == p2)
28 })
29}
30
31func TestStats_WallTime(t *testing.T) {
32 t.Run("add and load wall time", func(t *testing.T) {

Callers

nothing calls this directly

Calls 6

CopyMethod · 0.95
AddWallTimeMethod · 0.95
ContextWithEmptyStatsFunction · 0.85
LoadWallTimeMethod · 0.80
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected