Skip to content

Commit

Permalink
Reuse to test to assert the proper limit is used
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Snaps <[email protected]>
  • Loading branch information
alexsnaps committed Nov 21, 2024
1 parent b5f335d commit 64fc8d7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions limitador/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,10 @@ mod test {
assert!(limits.contains(&l));
assert_eq!(limits.iter().next().unwrap().max_value(), 42);

let _ = rl.check_rate_limited_and_update(&namespace.into(), &HashMap::default(), 1, false);
let r = rl
.check_rate_limited_and_update(&namespace.into(), &HashMap::default(), 1, true)
.unwrap();
assert_eq!(r.counters.first().unwrap().max_value(), 42);

let mut l = l.clone();
l.set_max_value(50);
Expand All @@ -730,6 +733,9 @@ mod test {
assert!(limits.contains(&l));
assert_eq!(limits.iter().next().unwrap().max_value(), 50);

let _ = rl.check_rate_limited_and_update(&namespace.into(), &HashMap::default(), 1, false);
let r = rl
.check_rate_limited_and_update(&namespace.into(), &HashMap::default(), 1, true)
.unwrap();
assert_eq!(r.counters.first().unwrap().max_value(), 50);
}
}

0 comments on commit 64fc8d7

Please sign in to comment.