Skip to content

Commit

Permalink
Add test that verifies the encoded bytes for the new method, to make …
Browse files Browse the repository at this point in the history
…sure they remain stable.

Signed-off-by: Hiram Chirino <[email protected]>
  • Loading branch information
chirino committed Jul 15, 2024
1 parent b0b979d commit 8b8d592
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions limitador/src/storage/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:";
Expand Down

0 comments on commit 8b8d592

Please sign in to comment.