_From @arbesfeld on October 20, 2016 19:50_
There are a few "Mock s3" servers that run in memory/disk. Since the google cloud storage and S3 APIs are the same, I was wondering if there was a way to use one of these servers with the Cloud Storage client? If not, what is the recommended way to use this API for local development?
_Copied from original issue: GoogleCloudPlatform/google-cloud-node#1731_
_From @stephenplusplus on October 20, 2016 19:52_
Can you link the mock libraries? I'm not sure they'd be the same, but soon we will support using a custom endpoint which accepts the requests from our API (#1630).
_From @arbesfeld on October 20, 2016 19:54_
Here are a few :
_From @nfarina on February 13, 2017 18:40_
I found that it was simple enough to create my own mock classes to emulate Google Cloud Storage just enough for my tests to pass. I posted my code to this gist in case anyone finds it useful as a starting point. Note: written in ES7 with Flow annotations.
I don't anticipate having an official solution for this. For offline development, you can use any HTTP request interceptor library that may exist. You can see the endpoints we hit in the source code, and if you want to log all of them:
const Storage = require('@google-cloud/storage')
const gcs = new Storage()
gcs.interceptors.push({
request: reqOpts => {
console.log(reqOpts)
return reqOpts
}
})
This will log all HTTP requests we make in the format the request module accepts.
Also, if you pass customEndpoint: true, it will skip the authentication step:
const Storage = require('@google-cloud/storage')
const gcs = new Storage({ customEndpoint: true })
Hopefully this is helpful. Feel free to ask any questions.
Most helpful comment
I don't anticipate having an official solution for this. For offline development, you can use any HTTP request interceptor library that may exist. You can see the endpoints we hit in the source code, and if you want to log all of them:
This will log all HTTP requests we make in the format the
requestmodule accepts.Also, if you pass
customEndpoint: true, it will skip the authentication step:Hopefully this is helpful. Feel free to ask any questions.