diff --git a/limitador/src/storage/keys.rs b/limitador/src/storage/keys.rs index 46b8292d..3fe5ded1 100644 --- a/limitador/src/storage/keys.rs +++ b/limitador/src/storage/keys.rs @@ -128,6 +128,22 @@ mod tests { key_for_counters_of_limit(&limit)) } + #[test] + fn key_for_limit_with_id_format() { + let mut limit = Limit::new( + "example.com", + 10, + 60, + vec!["req.method == 'GET'"], + vec!["app_id"], + ); + limit.set_id("test_id".to_string()); + assert_eq!( + "\u{2}\u{7}test_id".as_bytes(), + key_for_counters_of_limit(&limit) + ) + } + #[test] fn counter_key_and_counter_are_symmetric() { let namespace = "ns_counter:";