Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quick proposal of fake driver for testing #1

Closed
wants to merge 2 commits into from
Closed

quick proposal of fake driver for testing #1

wants to merge 2 commits into from

Conversation

maximehuylebroeck
Copy link

πŸ”— Linked issue

adonisjs/core#3833

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Created an extra driver with an in memory limiter to be able to test without redis/db's setup
So ideally in your .env.test you'll have the limiter driver on "fake" (or in the config) and it should work as any other driver.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@maximehuylebroeck
Copy link
Author

one small caveat is that the response of the remaining is negative in the fake.test.spec but I think this is a bug and I already created a ticket for that in the other project.

@thetutlage
Copy link
Member

I think, we should opt for the existing fakes API and add a Limiter.fake() method that switch to the memory driver and calling Limiter.restore() restores to the original set of drivers.

@maximehuylebroeck
Copy link
Author

I think, we should opt for the existing fakes API and add a Limiter.fake() method that switch to the memory driver and calling Limiter.restore() restores to the original set of drivers.

I agree was trying to figure out how it was done in the other addons, will try to change it when I have some time. I'll try to just add the in memory driver here and i'll create an other pull request for the one with the fake api.

@maximehuylebroeck
Copy link
Author

fyi @thetutlage they accepted my pr for the issue with the negative remaining, I'll update the dependency here as well. (animir/node-rate-limiter-flexible#172)

@maximehuylebroeck maximehuylebroeck deleted the Limiter-Fake-Driver-For-Testing-Proposal branch August 1, 2022 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants