mirror of
https://github.com/fsouza/fake-gcs-server.git
synced 2026-04-26 06:05:54 +03:00
[GH-ISSUE #458] Failing to read from an object I just wrote #88
Labels
No labels
bug
compatibility-issue
docker
documentation
enhancement
help wanted
needs information
pull-request
question
stale
unfortunate
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/fake-gcs-server#88
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @mipnw on GitHub (Mar 19, 2021).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/458
When I run the following unit test which tries to round trip an objet to GCP storage (upload then download and compare equality of the object content) I get failure
Error: Expected nil, but got: &url.Error{Op:"Get", URL:"https://storage.googleapis.com/my-bucket/my-object", Err:(*errors.errorString)(...)}I was expecting that test to pass. Having configured the fake gcs server for the HTTP scheme, I'm surprised by the "https" present in the URL of the error.
Is this my misunderstanding of how to use
fakestorage.NewServerWithOptions, or is this a bug in this Go package?My go.mod references
github.com/fsouza/fake-gcs-server v1.22.7. Usinggo version go1.15.6 darwin/amd64@fsouza commented on GitHub (Mar 19, 2021):
Yeah this is a bug in the client. If you change the server to "https" instead of "http" it should work.
I can push a fix later today (or if you're willing to give it a shot, we need to implement
Dialin addition toDialTLSin the http.Transport instance).@mipnw commented on GitHub (Mar 19, 2021):
ok I've modified the
fakestorage.Optionsto useScheme: "https". The test still fails atreader, err := mockClient.Bucket(bucketName).Object(objectName).NewReader(ctx)with error "storage: object doesn't exist"@fsouza commented on GitHub (Mar 19, 2021):
@mipnw you need to close the writer for it to create the object: https://pkg.go.dev/cloud.google.com/go/storage#ObjectHandle.NewWriter
@mipnw commented on GitHub (Mar 19, 2021):
I've fixed that test bug by closing the writer.
I'm still getting an error that "storage: object doesn't exist" but now it's not coming from a failure to write the object because I can see that object show up in my filesystem if I pass a
StorageRootoption. So part 1 (write the object) seems to work. But part 2 (read back the object), still gives me trouble.@fsouza commented on GitHub (Mar 20, 2021):
@mipnw I think the problem is the public host, if you remove that everything should work.
I'll fix the Client() method to return a client that supports both http and the custom public host.