-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
test(storage): improve object cleanup #8262
test(storage): improve object cleanup #8262
Conversation
Use the test helper mustDeleteObject function and make it resilient to transient failures. We should probably move other tests to do this at some point; could be a small fixit project. Fixes googleapis#8259
storage/integration_test.go
Outdated
if apiErr.HTTPCode() == 404 || apiErr.GRPCStatus().Code() == codes.NotFound { | ||
return | ||
} | ||
} | ||
h.t.Fatalf("%s: delete object %s from bucket %s: %v", loc(), o.ObjectName(), o.BucketName(), err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're in here, maybe we should also update this to use t.Helper()
instead of manually calling loc()
? Maybe that change could be made as part of the fixit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went ahead and just did this and got rid of loc()
@@ -272,7 +272,9 @@ func multiTransportTest(ctx context.Context, t *testing.T, | |||
opts ...option.ClientOption) { | |||
for transport, client := range initTransportClients(ctx, t, opts...) { | |||
t.Run(transport, func(t *testing.T) { | |||
defer client.Close() | |||
t.Cleanup(func() { | |||
client.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, turns out this is necessary b/c defer calls run before t.Cleanup calls :)
Use the test helper mustDeleteObject function and make it resilient to transient failures. Also switch to using t.Helper and t.Cleanup when possible for test helper funcs.
We should probably move other tests to do this at some point; could be a small fixit project.
Fixes #8259