Fix flakey ratelimit test #7105
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #6952
This deletes the flakey ratelimit test and adds four new ones:
publish_new_crate_ratelimit_hit
: Adds a row intopublish_limit_buckets
as though the user had been ratelimited, with alast_refill
far in the future to ensure the ratelimiting code is hitpublish_new_crate_ratelimit_expires
: Ditto, butlast_refill
is now juuuust far enough in the past for the ratelimit to hitpublish_new_crate_ratelimit_expires
: Defaults the ratelimit to one crate every day, then sets the override to allow the test user to publish two crates a day, and then test that they can publish 2 tests a day and no more.publish_new_crate_expired_override_ignored
: Ditto, but the overrideexpires_at
is set to just moments ago, and then checks that the test user has the normal (1-crate) limit.These tests should be infallible (well, assuming the code isn't broken, at least!) and I'm mostly only confident about that because
NaiveDateTime
has no time zones to worry about. Maybe try to avoid running it on a leap second boundary just in case.(CC @LawnGnome, when you have a second)