8000 expose Token.Raw unmarshalling to allow for easier testing · Issue #197 · golang/oauth2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

expose Token.Raw unmarshalling to allow for easier testing #197

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

Closed
jmhodges opened this issue Aug 29, 2016 · 0 comments
Closed

expose Token.Raw unmarshalling to allow for easier testing #197

jmhodges opened this issue Aug 29, 2016 · 0 comments

Comments

@jmhodges
Copy link
jmhodges commented Aug 29, 2016

This is a nice-to-have ticket.

So, the oauth2.Token that Slack returns contains data found in Token.Extra. I convert that oauth2.Token to a nicer to use Token-like struct by pulling the data out of Extra and checking the types and so on.

However, in order to test that, I can't just take the example response from their OAuth docs, json.Unmarshal it into the oauth2.Token and then run my conversion func on the returned oauth2.Token. That's because the oauth2.Token's raw field isn't set by simply unmarshalling the JSON and the conversion func using Extra will fail to see the data set. Instead, the raw field is set up by code inside a package internal to the oauth2 that the test code can't reach but is used by oauth2.Config.Exchange.

This is a bummer because that means my tests for deserialization need explicit calls to SetExtra in order to test the behavior correctly instead of being able to reuse the same string of testdata I was using for testing serialization.

It seems like moving an explicit UnmarshalJSON on to oauth2.Token would help. The code that's in the internal package would remain private, but the JSON unmarshalling would be easier to manage.

But maybe there was a reason for not having done so already that I'm not aware of. Let me know!

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Apr 18, 2025
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

No branches or pull requests

2 participants
0