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

Function TestMetricsNilSafe

coderd/aibridged/metrics_test.go:75–84  ·  view source on GitHub ↗

TestMetricsNilSafe asserts the helpers tolerate a nil receiver so callers can pass `nil` to disable metric updates without guarding every call site.

(t *testing.T)

Source from the content-addressed store, hash-verified

73// callers can pass `nil` to disable metric updates without guarding
74// every call site.
75func TestMetricsNilSafe(t *testing.T) {
76 t.Parallel()
77
78 var m *aibridged.Metrics
79 require.NotPanics(t, func() {
80 m.RecordReloadAttempt()
81 m.RecordReloadSuccess(nil)
82 m.Unregister()
83 })
84}

Callers

nothing calls this directly

Calls 3

RecordReloadAttemptMethod · 0.95
RecordReloadSuccessMethod · 0.95
UnregisterMethod · 0.95

Tested by

no test coverage detected