Question: I'm writing an appengine app in Go that uses [Google cloud storage](https://godoc.org/cloud.google.com/go/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](https://stackoverflow.com/questions/32613897/unit-testing-googles-cloud-storage-api), but it deals with python, and the linked [github issue](https://github.com/GoogleCloudPlatform/appengine-gcs-client/issues/21) indicates it's solved in a python-specific way).

How can I do this?

Answer: 
Cloud Storage on the Python Development server is emulated using local files with the Blobstore service, which is why the solution of using a Blobstore stub with testbed (also Python-specific) worked. However there is no such local emulation for Cloud Storage on the Go runtime.

As Sachin suggested, the way to unit test Cloud Storage is to use a mock. This is the way it's done internally and on other runtimes, such as [node](https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1032).
I would advice you reduce the mocks as much as possible you might need to use an hermetic approach to make it almost similar to the real thing .
<https://testing.googleblog.com/2012/10/hermetic-servers.html>