MCPcopy Create free account
hub / github.com/flant/shell-operator / newTestMetricStorage

Function newTestMetricStorage

pkg/task/queue/task_queue_compaction_test.go:184–196  ·  view source on GitHub ↗

newTestMetricStorage creates a metric storage mock with all required methods stubbed

(t *testing.T, expectCompaction bool)

Source from the content-addressed store, hash-verified

182
183// newTestMetricStorage creates a metric storage mock with all required methods stubbed
184func newTestMetricStorage(t *testing.T, expectCompaction bool) *metric.StorageMock {
185 metricStorage := metric.NewStorageMock(t)
186 metricStorage.HistogramObserveMock.Set(func(_ string, _ float64, _ map[string]string, _ []float64) {
187 })
188 // CounterAdd is only called during actual compaction
189 if expectCompaction {
190 metricStorage.CounterAddMock.Set(func(_ string, _ float64, _ map[string]string) {
191 })
192 }
193 // Note: GaugeSet is no longer called during compaction tests since metrics
194 // are updated asynchronously in a separate goroutine that runs with Start()
195 return metricStorage
196}
197
198func TestTaskQueueList_AddLast_GreedyMerge(t *testing.T) {
199 tests := []struct {

Callers 1

Calls 2

NewStorageMockFunction · 0.92
SetMethod · 0.45

Tested by

no test coverage detected