(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func 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 | |
| 67 | func TestStatsTracker_GetUsersStats(t *testing.T) { |
| 68 | tracker := New() |
nothing calls this directly
no test coverage detected