Package storage has unit, emulated integration tests, and integration tests against the real GCS service.
Assume that you're running from a directory which contains the google-cloud-go git repository.
git clone https://github.com/googleapis/google-cloud-go git clone https://github.com/googleapis/storage-testbench # emulator
go test ./google-cloud-go/storage -short
See https://github.com/googleapis/storage-testbench?tab=readme-ov-file#how-to-use-this-testbench for testbench setup instructions. After following those instructions, you should have an emulator running an HTTP server on port 9000 and a gRPC server on port 8888.
STORAGE_EMULATOR_HOST_GRPC="localhost:8888" STORAGE_EMULATOR_HOST="http://localhost:9000" go test ./google-cloud-go/storage -short -run="^Test(RetryConformance|.*Emulated)"
If you don't specify the -run filter, this will also run unit tests.
See the general setup instructions for more details. The GCS integration tests require:
Run with:
GCLOUD_TESTS_GOLANG_PROJECT_ID="${PROJECT_ID?}" GCLOUD_TESTS_GOLANG_KEY="${KEYFILE?}" \ go test ./google-cloud-go/storage -run="^Test.*Integration"