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

Function TestStatsTracker_UpdateStatsBatch

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

Source from the content-addressed store, hash-verified

263}
264
265func TestStatsTracker_UpdateStatsBatch(t *testing.T) {
266 tracker := New()
267 ctx := context.Background()
268
269 tracker.UpdateStatsBatch([]Sample{
270 {
271 PublicKey: "key1",
272 Email: "user1@example.com",
273 Rx: 1000,
274 Tx: 2000,
275 EndpointIP: "1.1.1.1",
276 },
277 {
278 PublicKey: "key2",
279 Email: "user2@example.com",
280 Rx: 3000,
281 Tx: 4000,
282 EndpointIP: "2.2.2.2",
283 },
284 })
285
286 resp := tracker.GetUsersStats(ctx, false)
287 if len(resp.Stats) != 4 {
288 t.Fatalf("expected 4 stats, got %d", len(resp.Stats))
289 }
290}
291
292func TestStatsTracker_UpdateStatsBatchDuplicateKeyLastWins(t *testing.T) {
293 tracker := New()

Callers

nothing calls this directly

Calls 3

UpdateStatsBatchMethod · 0.80
NewFunction · 0.70
GetUsersStatsMethod · 0.45

Tested by

no test coverage detected