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

Support ETags for Azure and Google Cloud [#176, #177] #183

Merged
merged 1 commit into from
Sep 9, 2024
Merged

Conversation

bdon
Copy link
Member

@bdon bdon commented Sep 9, 2024

  • NewRangeReaderEtag for gocloud buckets does provider-specific operations for set/get etag and error.
  • use generation ID as string etag for Google Cloud.

@akhenakh @msbarry

* NewRangeReaderEtag for gocloud buckets does provider-specific operations for set/get etag and error.
* use generation ID as string etag for Google Cloud.
Comment on lines +217 to +243
func TestSetProviderEtagAws(t *testing.T) {
var awsV1Req s3.GetObjectInput
assert.Nil(t, awsV1Req.IfMatch)
asFunc := func(i interface{}) bool {
v, ok := i.(**s3.GetObjectInput)
if ok {
*v = &awsV1Req
}
return true
}
setProviderEtag(asFunc, "123")
assert.Equal(t, aws.String("123"), awsV1Req.IfMatch)
}

func TestSetProviderEtagAzure(t *testing.T) {
var azOptions azblob.DownloadStreamOptions
assert.Nil(t, azOptions.AccessConditions)
asFunc := func(i interface{}) bool {
v, ok := i.(**azblob.DownloadStreamOptions)
if ok {
*v = &azOptions
}
return ok
}
setProviderEtag(asFunc, "123")
assert.Equal(t, azcore.ETag("123"), *azOptions.AccessConditions.ModifiedAccessConditions.IfMatch)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you have a similar test for google cloud?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't able to since conditions is not a public field of the gcp interface (is write-only through the If function)

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok got it. This is probably as good as we can get on testing short of standing up a mock implementation of the provider's API 👍

@bdon bdon merged commit ddd3524 into main Sep 9, 2024
4 checks passed
@bdon bdon deleted the azure-gcp-etags branch September 9, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants