30/32
Part 6 of 6 · Follow-upsLearn and do
What tests would you write?
- The edge at exactly
windowseconds, with one test either side of it. - A denied request followed by one that should pass.
- A window that crosses a round number.
- A key twice inside the look-back window.
- One request each from many clients, with a check that memory stays small. No correctness test finds a limiter that forgets nobody.
Turn the first test on the list above into code. Write passes_edge, which takes a limiter class such as RateLimiter, builds one limiter and checks the three calls around the edge. AllowsAll in the editor is a broken limiter that allows everything, to try your test on.