-
Notifications
You must be signed in to change notification settings - Fork 53
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
Fix regression caused by resolveOptions #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this and thanks for the fix. I would like to see this solved in a slightly different manner though. To me it doesn't make sense to be passing in nil
to resolveOptions
since it works by modifying the passed in options. Rather we should solve this by fixing the callers to make sure they are passing in valid api.ClientOptions
. Does that make sense? Additionally, if you are feeling up for it it would be great to add a test or two for resolveOptions
. I should have added some when I created the function but overlooked it.
Hey, that sounds good. I'll push some changes + new tests this afternoon. Cheers, |
@samcoe I was wondering if it was still desirable to allow the consumer to pass e.g: Then it would be up to the client methods to pass a valid
The other option would be to ask he consumer to provide an empty |
My thought would be that it should be up to the client methods to pass a valid |
I've pushed an implementation. I couldn't decide whether to include a nil check in resolveOptions so I left it out. I don't think it will ever be an issue to the consumer given that the client methods now handle the opts. Saying that though.. I'm more than happy to add something in if it's preferable! Currently pondering on tests... it feels tricky because of or we could pass in config to resolveOptions e.g
however I'm fairly fresh with Go so I might be overlooking something obvious. |
If opts was nil, resolveOptions would only update the local copy of opts. The pointer was never being updated and was therefore nil when passed to the New*Client methods.
We shouldn't allow passing nil to resolveOptions so this commit moves the responsibility up into the client methods.
Passing in config.Config as a dependency enables us to provide mocked config when testing.
Exporting FromString means that we can use it in external tests when mocking configuraton.
This commit adds test for the resolveOptions implementation. It also consumes the exported FromString function from the config package to give us a mocked config.Config instance.
Added some tests and rebased 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @chelnak, thanks for adding tests. Code looks good. I pushed one small change removing the double pointer argument that was remnants from the first approach and was unnecessary now.
@samcoe appreciated 😄 |
If opts was nil, resolveOptions would only update the local copy of opts. The pointer was never being updated and was therefore nil when passed to the New*Client methods.
Closes #17