tiny-counter 0.1.0

Track event counts across time windows with fixed memory and fast queries
Documentation
//! Tests for .count_nonzero() query method

use chrono::Utc;
use std::sync::Arc;
use tiny_counter::{EventStore, TestClock};

#[test]
fn query_count_nonzero() {
    let fixed_time = Utc::now();
    let clock = TestClock::build_for_testing_at(fixed_time);

    let store = EventStore::builder()
        .with_clock(Arc::new(clock.clone()))
        .track_days(7)
        .build()
        .unwrap();

    store.record("event");

    // Only 1 day has data
    let count = store.query("event").last_days(7).count_nonzero();
    assert_eq!(count, Some(1));
}