Description
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!