-
|
Hi, I am integrating google-cloud-storage and struggling to design testable logic for retrieving an object's size at rest. The SDK exposes this via the control plane, which works but isn't supported by standard test tools like fake-gcs-server, as they focus on the data plane. I tried using the data plane instead - hoping for a mechanism to request with alt=json or similar, but the SDK always sends media requests (alt=media), so that path doesn't work. My fallback was to trigger a download without consuming the stream and read the size from the response headers. However, this relies on the x-goog-stored-content-length header, which, according to Gemini and ChatGPT, may be absent in some cases. Do you have any suggestions for a reliable and testable approach? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Does
Hmm... not in my experience, but the public documentation is ambiguous (let me ask internally). If that is the case, then you have a different problem beyond testing: the application won't be able to get the object size in production either, no?
For testable: can you use mocks? You can mock both the control and data plane operations in the Rust client library. For reliable: if you must have the object size, query the object metadata. That may require fixing |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for getting back @coryan I used AI to analyse the codebase, which returned with the following findings:
I have checked and can confirm that With regards to the Mocks work fine, but emulators are more reliable and better suited for local end-to-end testing. |
Beta Was this translation helpful? Give feedback.
You are right. I completely forgot about that.
That is the size of the download. Which can be smaller than the object (say if you are downloading a range), or larger (if the object is being decompressed on the fly). It may also be omitted.
I checked internally and …