storage: unflake TestIntegration_WriterContentType

Add a retry to all calls to the writeObject method (used by
multiple integration tests). After we finish related work on
improving retries in the client for write operations, this
can probably be removed.

Fixes #2394

Change-Id: I5a0bab0f9cb0a2a2f816cc0a172c8fa3e019bdae
Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/57152
Reviewed-by: Frank Natividad <franknatividad@google.com>
Reviewed-by: Cody Oss <codyoss@google.com>
diff --git a/storage/integration_test.go b/storage/integration_test.go
index 84cfeae..8b77634 100644
--- a/storage/integration_test.go
+++ b/storage/integration_test.go
@@ -3391,16 +3391,20 @@
 }
 
 func writeObject(ctx context.Context, obj *ObjectHandle, contentType string, contents []byte) error {
-	w := obj.NewWriter(ctx)
-	w.ContentType = contentType
-	w.CacheControl = "public, max-age=60"
-	if contents != nil {
-		if _, err := w.Write(contents); err != nil {
-			_ = w.Close()
-			return err
+	// TODO: remove retry once retry logic in the client has been improved.
+	// https://github.com/googleapis/google-cloud-go/issues/2395
+	return retry(ctx, func() error {
+		w := obj.NewWriter(ctx)
+		w.ContentType = contentType
+		w.CacheControl = "public, max-age=60"
+		if contents != nil {
+			if _, err := w.Write(contents); err != nil {
+				_ = w.Close()
+				return err
+			}
 		}
-	}
-	return w.Close()
+		return w.Close()
+	}, nil)
 }
 
 // loc returns a string describing the file and line of its caller's call site. In