use crate::refill_rate::RefillRate;
use super::{QuotaPolicy, QuotaPool};

#[test]
fn pool_auto_creates_quota() {
    let policy = QuotaPolicy::new()
        .set_capacity(10.0)
        .set_refill_rate(RefillRate::per_sec(3)); // TODO: Add a custom time tick in refill rate rather than ticking all the time

    let pool = QuotaPool::new(policy, 10);

    let mut results = vec![];
    for _ in 0..100 {
        results.push(pool.consume("testing", 1));
    }

    assert_eq!(results.iter().filter(|r| r.is_ok()).count(), 10);
    assert_eq!(results.iter().filter(|r| r.is_err()).count(), 90);
}
