I'm writing an appengine app in Go that uses Google cloud storage.
For example, my "reading" code looks like:
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 a context from appengine.
When I run this code in a unit test (using aetest
), it actually sends requests to my cloud storage; I'd like to run this hermetically instead, similar to how aetest
allows fake datastore calls.
(Possibly related question, but it deals with python, and the linked github issue indicates it's solved in a python-specific way).
How can I do this?