Skip to content

Commit 25bde60

Browse files
author
Ajay Kannan
committed
Testing doc fixes and adding/updating examples
1 parent 3751460 commit 25bde60

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

TESTING.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,32 @@ You can test against a remote datastore emulator as well. To do this, set the `
3838
Datastore localDatastore = DatastoreFactory.instance().get(options);
3939
```
4040

41-
Note that the remote datastore must be running before your tests are run. Also note that the `host` argument must start with "http://" or "https://".
41+
Note that the remote datastore must be running before your tests are run. Also note that the `host` argument must start with "http://" or "https://" if you are testing with a remote machine.
4242

4343

4444
### Testing interactions with Storage
4545

4646
There currently 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:
4747

48-
1. Create a test Google App Engine project.
48+
1. Create a test Google Cloud project.
4949

50-
2. Create and download a JSON key by going to the Google Developer's Console and clicking API's & Auth > Credentials > Add Credentials > Service Credentials. Choose "JSON", download the file, and note its location.
50+
2. Create and 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].
5151

52-
3. Set environment variables `GCLOUD_TESTS_PROJECT_ID` and `GCLOUD_TESTS_KEY_PATH` according to your test project's ID and the location of the newly-downloaded JSON key file.
52+
3. Set environment variables `GCLOUD_TESTS_PROJECT_ID` and `GCLOUD_TESTS_KEY` according to your test project's ID and the location of the newly-downloaded JSON key file. On linux and mac, for example,
53+
```
54+
export GCLOUD_TESTS_PROJECT_ID=<project id>
55+
export GCLOUD_TESTS_KEY=/path/to/JSON/key.json
56+
```
5357

5458
4. Create and and use a `RemoteGcsHelper` object.
55-
Here is an example that uses the RemoteGcsHelper to create a bucket and clear the bucket at the end of the test.
59+
Here is an example that uses the `RemoteGcsHelper` to create a bucket and clear the bucket at the end of the test.
5660
```java
5761
RemoteGcsHelper gcsHelper = RemoteGcsHelper.create();
5862
Storage storage = StorageFactory.instance().get(gcsHelper.options());
5963
String bucket = RemoteGcsHelper.generateBucketName();
6064
storage.create(BucketInfo.of(bucket));
6165
// Do tests using Storage
62-
RemoteGcsHelper.deleteBucketRecursively(storage, bucket, 5, TimeUnit.SECONDS);
66+
RemoteGcsHelper.forceDelete(storage, bucket, 5, TimeUnit.SECONDS);
6367
```
68+
69+
[cloud-platform-storage-authentication]:https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts

0 commit comments

Comments
 (0)