Skip to content

Commit

Permalink
test(storage): use t.Cleanup for requesterpays test (googleapis#5792)
Browse files Browse the repository at this point in the history
Buckets will be cleaned up anyway, so I added the error check back to the cleanup
  • Loading branch information
BrennaEpp authored Mar 23, 2022
1 parent 8e4c029 commit d6dea46
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions storage/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2920,7 +2920,9 @@ func TestIntegration_RequesterPays(t *testing.T) {
if err := requesterPaysBucket.ACL().Set(ctx, ACLEntity("user-"+otherUserEmail), RoleOwner); err != nil {
t.Fatalf("set ACL: %v", err)
}
defer h.mustDeleteBucket(requesterPaysBucket)
t.Cleanup(func() {
h.mustDeleteBucket(requesterPaysBucket)
})

// Make sure the object exists, so we don't get confused by ErrObjectNotExist.
// The later write we perform may fail so we always write to the object as the user
Expand Down Expand Up @@ -2980,22 +2982,22 @@ func TestIntegration_RequesterPays(t *testing.T) {
// Copy
_, err = bucket.Object("copy").CopierFrom(bucket.Object(objectName)).Run(ctx)
checkforErrors("copy", err)
// Delete created "copy" object
defer func() {
if err := bucket.Object("copy").Delete(ctx); err != nil {
t.Fatalf("could not delete copy: %v", err)
}
}()
// Delete "copy" object, if created
if err == nil {
t.Cleanup(func() {
h.mustDeleteObject(bucket.Object("copy"))
})
}

// Compose
_, err = bucket.Object("compose").ComposerFrom(bucket.Object(objectName), bucket.Object("copy")).Run(ctx)
checkforErrors("compose", err)
// Delete created "compose" object
defer func() {
if err := bucket.Object("compose").Delete(ctx); err != nil {
t.Fatalf("could not delete compose: %v", err)
}
}()
// Delete "compose" object, if created
if err == nil {
t.Cleanup(func() {
h.mustDeleteObject(bucket.Object("compose"))
})
}

// Delete object
if err = bucket.Object(objectName).Delete(ctx); err != nil {
Expand All @@ -3004,9 +3006,7 @@ func TestIntegration_RequesterPays(t *testing.T) {
}
checkforErrors("delete object", err)
})

}

}

func TestIntegration_Notifications(t *testing.T) {
Expand Down

0 comments on commit d6dea46

Please sign in to comment.