MCPcopy Create free account
hub / github.com/PasarGuard/node / TestStatsTracker_GetStats

Function TestStatsTracker_GetStats

pkg/stats/tracker_test.go:21–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19}
20
21func TestStatsTracker_GetStats(t *testing.T) {
22 tracker := New()
23 ctx := context.Background()
24
25 updateSample(tracker, "key1", "user@example.com", 1000, 2000, "1.2.3.4")
26
27 resp := tracker.GetStats(ctx, []string{"key1"}, false)
28 if len(resp.Stats) != 2 {
29 t.Fatalf("Expected 2 stats, got %d", len(resp.Stats))
30 }
31
32 for _, s := range resp.Stats {
33 if s.Type == "downlink" && s.Value != 1000 {
34 t.Errorf("Expected rx=1000, got %d", s.Value)
35 }
36 if s.Type == "uplink" && s.Value != 2000 {
37 t.Errorf("Expected tx=2000, got %d", s.Value)
38 }
39 }
40}
41
42func TestStatsTracker_GetStatsReset(t *testing.T) {
43 tracker := New()

Callers

nothing calls this directly

Calls 3

updateSampleFunction · 0.85
NewFunction · 0.70
GetStatsMethod · 0.65

Tested by

no test coverage detected