Skip to content

Commit

Permalink
storage: Fix typos in some field names and add tests
Browse files Browse the repository at this point in the history
Change-Id: Ibd115c166da4c8a304129cb99299aefd14bfe7e1
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/49970
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jean de Klerk <deklerk@google.com>
Reviewed-by: Chris Cotter <cjcotter@google.com>
  • Loading branch information
eliben authored and tritone committed Jan 2, 2020
1 parent bd2d9b3 commit b7a6a74
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
29 changes: 29 additions & 0 deletions storage/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ func TestIntegration_Objects(t *testing.T) {

testObjectIterator(t, bkt, objects)
testObjectsIterateSelectedAttrs(t, bkt, objects)
testObjectsIterateAllSelectedAttrs(t, bkt, objects)

// Test Reader.
for _, obj := range objects {
Expand Down Expand Up @@ -1075,6 +1076,34 @@ func testObjectsIterateSelectedAttrs(t *testing.T, bkt *BucketHandle, objects []
}
}

func testObjectsIterateAllSelectedAttrs(t *testing.T, bkt *BucketHandle, objects []string) {
// Tests that all selected attributes work - query succeeds (without actually
// verifying the returned results).
query := &Query{Prefix: ""}
var selectedAttrs []string
for k := range attrToFieldMap {
selectedAttrs = append(selectedAttrs, k)
}
query.SetAttrSelection(selectedAttrs)

count := 0
it := bkt.Objects(context.Background(), query)
for {
_, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
log.Fatal(err)
}
count++
}

if count != len(objects) {
t.Errorf("count = %v, want %v", count, len(objects))
}
}

func TestIntegration_SignedURL(t *testing.T) {
if testing.Short() { // do not test during replay
t.Skip("Integration tests skipped in short mode")
Expand Down
4 changes: 2 additions & 2 deletions storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ var attrToFieldMap = map[string]string{
"ContentEncoding": "contentEncoding",
"ContentDisposition": "contentDisposition",
"Size": "size",
"MD5": "md5hash",
"MD5": "md5Hash",
"CRC32C": "crc32c",
"MediaLink": "mediaLink",
"Metadata": "metadata",
Expand All @@ -1174,7 +1174,7 @@ var attrToFieldMap = map[string]string{
"KMSKeyName": "kmsKeyName",
"Created": "timeCreated",
"Deleted": "timeDeleted",
"Updated": "timeUpdated",
"Updated": "updated",
"Etag": "etag",
}

Expand Down

0 comments on commit b7a6a74

Please sign in to comment.