You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
This is a nice-to-have ticket.
So, the
oauth2.Token
that Slack returns contains data found inToken.Extra
. I convert thatoauth2.Token
to a nicer to use Token-like struct by pulling the data out ofExtra
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 theoauth2.Token
and then run my conversion func on the returnedoauth2.Token
. That's because theoauth2.Token
'sraw
field isn't set by simply unmarshalling the JSON and the conversion func usingExtra
will fail to see the data set. Instead, theraw
field is set up by code inside a package internal to theoauth2
that the test code can't reach but is used byoauth2.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 tooauth2.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!
The text was updated successfully, but these errors were encountered: