MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestPoolStats_ActiveCalculation

Function TestPoolStats_ActiveCalculation

pkg/metrics/pool_stats_test.go:70–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

68}
69
70func TestPoolStats_ActiveCalculation(t *testing.T) {
71 metrics.ResetPoolStats()
72
73 metrics.RecordNamedPoolGet("parser")
74 metrics.RecordNamedPoolGet("parser")
75 metrics.RecordNamedPoolPut("parser")
76
77 stats := metrics.GetPoolStats()
78 ps := stats["parser"]
79 if ps.Gets != 2 {
80 t.Errorf("expected Gets=2, got %d", ps.Gets)
81 }
82 if ps.Puts != 1 {
83 t.Errorf("expected Puts=1, got %d", ps.Puts)
84 }
85 if ps.Active() != 1 {
86 t.Errorf("expected Active()=1, got %d", ps.Active())
87 }
88}
89
90func TestPoolStats_ResetClearsCounters(t *testing.T) {
91 metrics.RecordNamedPoolGet("ast")

Callers

nothing calls this directly

Calls 6

ResetPoolStatsFunction · 0.92
RecordNamedPoolGetFunction · 0.92
RecordNamedPoolPutFunction · 0.92
GetPoolStatsFunction · 0.92
ActiveMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected