MCPcopy Index your code
hub / github.com/coder/coder / assertGauges

Function assertGauges

coderd/x/chatd/streamcollector_internal_test.go:146–161  ·  view source on GitHub ↗
(t *testing.T, reg *prometheus.Registry, want gaugeExpectations)

Source from the content-addressed store, hash-verified

144}
145
146func assertGauges(t *testing.T, reg *prometheus.Registry, want gaugeExpectations) {
147 t.Helper()
148 families, err := reg.Gather()
149 require.NoError(t, err)
150
151 got := map[string]float64{}
152 for _, f := range families {
153 require.Len(t, f.GetMetric(), 1, "metric %q should have exactly one sample", f.GetName())
154 got[f.GetName()] = f.GetMetric()[0].GetGauge().GetValue()
155 }
156
157 assert.Equal(t, want.active, got["coderd_chatd_streams_active"], "streams_active")
158 assert.Equal(t, want.bufferMax, got["coderd_chatd_stream_buffer_size_max"], "buffer_size_max")
159 assert.Equal(t, want.bufferTotal, got["coderd_chatd_stream_buffer_events"], "buffer_events")
160 assert.Equal(t, want.subscribers, got["coderd_chatd_stream_subscribers"], "subscribers")
161}
162
163func newSubscribers(t *testing.T, n int) map[uuid.UUID]chan codersdk.ChatStreamEvent {
164 t.Helper()

Callers 1

TestStreamStateCollectorFunction · 0.85

Calls 5

HelperMethod · 0.65
LenMethod · 0.45
GetNameMethod · 0.45
GetValueMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected