tiny-counter 0.1.0

Track event counts across time windows with fixed memory and fast queries
Documentation
//! Config compatibility tests - export/import across different configurations.
//!
//! Tests that counters can be transferred between stores with different configs.

use tiny_counter::EventStore;

#[test]
fn export_import_with_matching_configs() {
    // Source store with 24 hour buckets
    let source_store = EventStore::builder().track_hours(24).build().unwrap();

    source_store.record_count("event", 100);

    let exported = source_store.export_all().unwrap();

    // Target store with same config
    let target_store = EventStore::builder().track_hours(24).build().unwrap();

    target_store.import_all(exported).unwrap();

    // Data should be imported successfully
    assert_eq!(target_store.query("event").last_hours(24).sum(), Some(100));
}

#[test]
fn export_import_with_compatible_configs() {
    let source_store = EventStore::new(); // Default config

    source_store.record_count("event", 100);

    let exported = source_store.export_all().unwrap();

    let target_store = EventStore::new(); // Same default config

    target_store.import_all(exported).unwrap();

    assert_eq!(target_store.query("event").last_days(1).sum(), Some(100));
}