h2non / gock

HTTP traffic mocking and testing made easy in Go ༼ʘ̚ل͜ʘ̚༽
https://pkg.go.dev/github.com/h2non/gock
MIT License
2.04k stars 106 forks source link

How to test google api using gock? #96

Closed milley23 closed 11 months ago

milley23 commented 2 years ago

Hi, I am working with Google Analytics API , and need to create unit testing for that using gock. Is it possible?

how to mock this part ?? analyticsService, _ := analytics.NewService(ctx, option.WithCredentialsJSON(cred))

it asks me to put the real private key on Credential JSON or I will get this following error: private key should be a PEM or plain PKCS1 or PKCS8; parse error: asn1: structure error: tags don't match (16 vs {class:0 tag:8 length:1214 isCompound:true}) {optional:false explicit:false application:false private:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} pkcs1PrivateKey

Thank you.