Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Handle duplicate route error gracefully #813

Merged

Conversation

pradovic
Copy link
Contributor

@pradovic pradovic commented Oct 27, 2019

Should fix #519. I took a really easy & straightforward approach here, as this is my first PR. Let me know if you guys would like it to be solved differently, and I will be more then happy to update the PR or create a new one.

🌷 Maybe it would be useful to add tests for route.rs. Would be happy to do it.

Copy link
Contributor

@ashleygwilliams ashleygwilliams left a comment

Choose a reason for hiding this comment

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

hey @pradovic ! thank you so much for filing this! i think it looks great! as for your ask re: tests, i think those would be fantastic and if you wanted you could add the first test for the condition you wrote this PR for! we could then do some more in another PR. how does that sound? thanks again for the thoughtful PR! we really appreciate it!

@pradovic
Copy link
Contributor Author

pradovic commented Oct 28, 2019

hey @ashleygwilliams, thanks for the super-fast and super-kind response!
I have started writing the unit tests, but I don't see a way to implement proper unit tests without partial refactor of the original code, as it is calling public methods directly, and not really working with traits.

Specifically, it directly calls http::auth_client(None, user) which can not be easily mocked.
Would it be OK to merge this PR without the tests? I can create a separate PR with the minor refactor + the tests for this one?

Much appreciated!

@ashleygwilliams
Copy link
Contributor

ashleygwilliams commented Oct 28, 2019

@pradovic sounds like a plan to me! do you want to file an issue for the plan you have? i think my team would be interested in discussing it with you :) ... in the meantime, we should be able to get this in for the next release, 1.6.0- which is currently aiming to be released on nov 8! thanks again for contributing!! <3

@pradovic
Copy link
Contributor Author

@ashleygwilliams Sounds good to me! I will open an issue very soon! Thanks a lot!

let msg;
if res.status().as_u16() == 10020 {
msg = format!(
"{} There was an error creating your route. Worker with a different name was found on {} route.\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @pradovic - thanks so much for this thoughtful PR. I have a minor suggestion for the wording of the error message to make it a bit more actionable. Let me know what you think!

Suggested change
"{} There was an error creating your route. Worker with a different name was found on {} route.\n",
"{} A worker with a different name was previously deployed to `{}`. If you would like to overwrite that worker, you will need to change `name` in your `wrangler.toml` to match the currently deployed worker, or navigate to https://dash.cloudflare.com/workers and rename or delete that worker.\n",

Copy link
Contributor Author

@pradovic pradovic Oct 28, 2019

Choose a reason for hiding this comment

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

Hey @EverlastingBugstopper, thanks for the feedback, I was wondering how to phrase it better! Sounds good to me! I have updated the PR with suggested change.

Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper left a comment

Choose a reason for hiding this comment

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

looks great!

@ashleymichal
Copy link
Contributor

ashleymichal commented Oct 28, 2019

@pradovic Thanks for the PR! We're definitely looking at improving the testability of a lot of our codebase. One of my big initiatives for this quarter is to shift all of our API calls into cloudflare-rs, which provides a lovely mock api client struct for exactly these kinds of unit tests. i'll probably link to that initiative from this issue: #63, so keep an eye out if you'd like to help with that!

@pradovic
Copy link
Contributor Author

@ashleymichal Thanks a lot for the info, that sounds awesome! I will keep an eye on that one!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle duplicate route API error
4 participants