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

Delete all stubs #89

Merged
merged 2 commits into from
Mar 25, 2021
Merged

Delete all stubs #89

merged 2 commits into from
Mar 25, 2021

Conversation

joshystuart
Copy link
Contributor

I've added a DELETE method on the root admin url eg.

DELETE localhost:5000

This will delete all stubs. It's quite handy for something like functional testing where you are setting up / tearing down fixture data for each test. The alternative is having to maintain a list of IDs for every stub you create.

Copy link
Owner

@mrak mrak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request! I have an ask before merging.

this.endpoints.delete(id, callback);
if (id) {
this.endpoints.delete(id, callback);
} else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change I would ask is to ensure that the request was to / to delete everything, instead of deleting everything if an id wasn't captured.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries 👍

Out of curiosity; what is an example url that might be something without an id? Is it just anything that isn't a number eg. /test? Or with multiple directories in the path? eg. /123/test. I just want to make sure I cover the right scenarios in a test.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are good examples. I think the code as-is may actually work correctly (due to multiple checks against urlPattern) but for a "delete everything" capability it is good to have tests ensuring it works as intended only on / in case other capabilities are added later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I'll sort that out today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Owner

@mrak mrak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mrak mrak merged commit 1765850 into mrak:master Mar 25, 2021
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