use std::collections::BTreeMap;
use serde::{Deserialize, Serialize};
use crate::BucketKey;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QuotaSpec {
pub stratify_format_version: u32,
pub input: String,
pub by: Vec<String>,
pub quotas: BTreeMap<BucketKey, usize>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn round_trips_through_json() {
let mut quotas = BTreeMap::new();
quotas.insert("phase:opening:".to_string(), 100);
let spec = QuotaSpec {
stratify_format_version: 1,
input: "in.jsonl".to_string(),
by: vec!["phase".to_string()],
quotas,
};
let json = serde_json::to_string(&spec).unwrap();
let back: QuotaSpec = serde_json::from_str(&json).unwrap();
assert_eq!(back.quotas.get("phase:opening:"), Some(&100));
}
}