I am writing a Go app that uses Google Cloud Storage .
For example, my βreadingβ code looks like this:
client, err := storage.NewClient(ctx) if err != nil { return nil, err } defer func() { if err := client.Close(); err != nil { panic(err) } }() r, err := client.Bucket(BucketName).Object(id).NewReader(ctx) if err != nil { return nil, err } defer r.Close() return ioutil.ReadAll(r)
... where ctx is the context from appengine.
When I run this code in a unit test (using aetest ), it actually sends requests to my cloud storage; Instead, I would like to do this hermetically, just as aetest resolves fake data warehouse calls.
(Perhaps a related question , but it deals with python, and the github related issue indicates that it has been resolved in a python-specific way).
How can i do this?
google-app-engine google-cloud-storage unit-testing go
Jesse beder
source share