Skip to content

Commit b52ded3

Browse files
author
Ajay Kannan
committed
make testing directions more standardized between datastore and storage
1 parent 396db25 commit b52ded3

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

TESTING.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ You can test against a remote datastore emulator as well. To do this, set the `
4040

4141
Note that the remote datastore must be running before your tests are run.
4242

43-
4443
### Testing code that uses Storage
4544

4645
Currently, there isn't an emulator for Google Cloud Storage, so an alternative is to create a test project. `RemoteGcsHelper` contains convenience methods to make setting up and cleaning up the test project easier. To use this class, follow the steps below:
@@ -49,15 +48,22 @@ Currently, there isn't an emulator for Google Cloud Storage, so an alternative i
4948

5049
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].
5150

52-
3. Create and use a `RemoteGcsHelper` object using your project ID and JSON key.
53-
Here is an example that uses the `RemoteGcsHelper` to create a bucket and clear the bucket at the end of the test.
51+
3. Create a `RemoteGcsHelper` object using your project ID and JSON key.
52+
Here is an example that uses the `RemoteGcsHelper` to create a bucket.
5453
```java
5554
RemoteGcsHelper gcsHelper = RemoteGcsHelper.create(PROJECT_ID, "/path/to/my/JSON/key.json");
5655
Storage storage = StorageFactory.instance().get(gcsHelper.options());
5756
String bucket = RemoteGcsHelper.generateBucketName();
5857
storage.create(BucketInfo.of(bucket));
59-
// Do tests using Storage
58+
```
59+
60+
4. Run your tests.
61+
62+
5. Clean up the test project by using `forceDelete` to clear any buckets used.
63+
Here is an example that clears the bucket created in Step 3 with a timeout of 5 seconds.
64+
```java
6065
RemoteGcsHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS);
6166
```
6267

68+
6369
[cloud-platform-storage-authentication]:https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts

0 commit comments

Comments
 (0)