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

Function TestStatsTracker_GetStatsReset

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

Source from the content-addressed store, hash-verified

40}
41
42func TestStatsTracker_GetStatsReset(t *testing.T) {
43 tracker := New()
44 ctx := context.Background()
45
46 updateSample(tracker, "key1", "user@example.com", 1000, 2000, "1.2.3.4")
47 updateSample(tracker, "key1", "user@example.com", 2000, 4000, "1.2.3.4")
48
49 resp := tracker.GetStats(ctx, []string{"key1"}, true)
50 for _, s := range resp.Stats {
51 if s.Type == "downlink" && s.Value != 2000 {
52 t.Errorf("Expected rx=2000, got %d", s.Value)
53 }
54 if s.Type == "uplink" && s.Value != 4000 {
55 t.Errorf("Expected tx=4000, got %d", s.Value)
56 }
57 }
58
59 resp2 := tracker.GetStats(ctx, []string{"key1"}, false)
60 for _, s := range resp2.Stats {
61 if s.Value != 0 {
62 t.Errorf("Expected 0 after reset, got %d", s.Value)
63 }
64 }
65}
66
67func TestStatsTracker_GetUsersStats(t *testing.T) {
68 tracker := New()

Callers

nothing calls this directly

Calls 3

updateSampleFunction · 0.85
NewFunction · 0.70
GetStatsMethod · 0.65

Tested by

no test coverage detected