Closed aeneasr closed 6 years ago
At some point (in 2017, ,I believe) there will be an emulator for Cloud Storage.
Just to add to the original post here, an emulator sounds good, but it would be nice for more interfaces be used for the purposes of mocking. I've been able to get around this in my own unit tests, but it doesn't look particularly nice and can be a little tricky to get set up.
Is there any ETA on that emulator?
Edit: I've actually been unsuccessful in getting the interfaces I need right so far, the amount of wrapping and stubbing is making the actual code itself much harder to follow as a result too.
I'm going to look into building an in-memory mock/fake. I don't have an ETA for that either :(
https://code-review.googlesource.com/12970 is a POC for a storage testing framework. Please comment here or on the CL.
We now have two new ways to test the storage client:
These should suffice for nearly all unit testing purposes. Re-open if not.
For anyone landing here from Google who's trying to test their storage client, here's an example of using httpreplay: https://github.com/googleapis/google-cloud-go/blob/b560988bf949eec95fc850e4bf7fad9040260b55/storage/integration_test.go
How can I test my code that depends on
*storage.Client
? For example, I want to write a test that tests this code:gomock is not an option as there are no interfaces available, and it would be way easier to set up a preconfigured mock gcp storage server instead.