tiny-counter 0.1.0

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

use tiny_counter::{EventStore, TimeUnit};

#[test]
fn allowed_returns_true_when_check_passes() {
    let store = EventStore::new();

    let allowed = store
        .limit()
        .at_most("action", 10, TimeUnit::Hours)
        .allowed("action");

    assert!(allowed);
}

#[test]
fn allowed_returns_false_when_check_fails() {
    let store = EventStore::new();

    // Fill to limit
    for _ in 0..10 {
        store.record("action");
    }

    let allowed = store
        .limit()
        .at_most("action", 10, TimeUnit::Hours)
        .allowed("action");

    assert!(!allowed);
}