Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Testing code that uses Google Cloud Storage

`RemoteStorageHelper` contains convenience methods to make setting up and cleaning up the test buckets easier. To use this class:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't a complete story for Storage but it does resolve the broken link. I think there's an additional AI here to flesh this file out more?


1. Create a test Google Cloud project.

2. Download a JSON service account credentials file from the Google Developer's Console. See more about this on the [Google Cloud Platform Storage Authentication page][cloud-platform-storage-authentication].

3. Create a `RemoteStorageHelper` object using your project ID and JSON key.
Here is an example that uses the `RemoteStorageHelper` to create a bucket.
```java
RemoteStorageHelper helper =
RemoteStorageHelper.create(PROJECT_ID, new FileInputStream("/path/to/my/JSON/key.json"));
Storage storage = helper.getOptions().getService();
String bucket = RemoteStorageHelper.generateBucketName();
storage.create(BucketInfo.of(bucket));
```

4. Run your tests.

5. Clean up the test project by using `forceDelete` to clear any buckets used.
Here is an example that clears the bucket created in Step 3 with a timeout of 5 seconds.
```java
RemoteStorageHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS);
```
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
* RemoteStorageHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS);
* }</pre>
*
* @see <a
* href="https://github.com/googleapis/google-cloud-java/blob/master/TESTING.md#testing-code-that-uses-storage">
* Google Cloud Java tools for testing</a>
* @see <a href="https://github.com/googleapis/java-storage/blob/main/TESTING.md">Google Cloud
* Storage testing</a>
*/
package com.google.cloud.storage.testing;