dnaeon / go-vcr

Record and replay your HTTP interactions for fast, deterministic and accurate tests
BSD 2-Clause "Simplified" License
1.26k stars 78 forks source link

go-vcr and using it to test GitHub Client with Oauth 2 #69

Closed joesustaric closed 2 years ago

joesustaric commented 2 years ago

Hi there,

I'd like to use this library to test with the GitHub client.

From their docs I would need to inject an Oauth2 client to handle the Oauth2 dance https://github.com/google/go-github/blob/master/example/tokenauth/main.go#L29

Is it possible to use go-vcr with an Oauth2 client to save responses and replay them later?

My understanding is that the recorder needs to be injected into the client as the Transport https://github.com/dnaeon/go-vcr/blob/master/example/https_test.go#L46

I'm still poking around both libraries but don't know a lot about the internals of the Oauth2 and http libraries. Is this even possible?

Any assistance would be appreciated

Thanks

dnaeon commented 2 years ago

Hey @joesustaric ,

Please check issue https://github.com/dnaeon/go-vcr/issues/59, which discusses go-github and go-vcr in particular.

joesustaric commented 2 years ago

Oh yes thank you - I think that's what I needed.

👍