Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(storage): fix emulated tests for metadata on read #11387

Merged
merged 3 commits into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions storage/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,8 @@ func TestOpenReaderEmulated(t *testing.T) {
})
}

func TestOpenReaderEmulated_Metadata(t *testing.T) {
transportClientTest(context.Background(), t, func(t *testing.T, ctx context.Context, project, bucket string, client storageClient) {
func TestOpenReaderMetadataEmulated(t *testing.T) {
transportClientTest(skipHTTP("metadata on read not supported in testbench rest server"), t, func(t *testing.T, ctx context.Context, project, bucket string, client storageClient) {
// Populate test data.
_, err := client.CreateBucket(ctx, project, bucket, &BucketAttrs{
Name: bucket,
Expand Down Expand Up @@ -849,8 +849,13 @@ func TestOpenReaderEmulated_Metadata(t *testing.T) {
"Custom-Key": "custom-value",
"Some-Other-Key": "some-other-value",
}
if diff := cmp.Diff(r.Metadata(), expectedMetadata); diff != "" {
t.Fatalf("Object Metadata: got(-),want(+):\n%s", diff)
gotMetaData := r.Metadata()
// Testbench specific metadata is included for testing purposes.
for key, expectedValue := range expectedMetadata {
actualValue, ok := gotMetaData[key]
if !ok || actualValue != expectedValue {
t.Fatalf("Object Metadata: Expected key %q with value %q, but got %q", key, expectedValue, actualValue)
Comment on lines +854 to +857
Copy link
Contributor

@BrennaEpp BrennaEpp Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this fails if one of the expected keys is not in the metadata (!ok would return true?), but can you/did you double check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested against the testbench manually and good news it's running in kokoro now too. So this should fail if an expected key is not in gotMetadata or if there is a mismatch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thanks

}
}

})
Expand Down
Loading