-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: fix broken link for TESTING.md (#2126)
Fixes b/290932427
- Loading branch information
1 parent
de80b66
commit fe9662d
Showing
2 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
|
||
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); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters