You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Renames LocalGcdHelper --> LocalDatastoreHelper and RemoteGcsHelper --> RemoteStorageHelper, also removes main()-related functions from LocalDatastoreHelper
Copy file name to clipboardExpand all lines: TESTING.md
+27-26
Original file line number
Diff line number
Diff line change
@@ -11,56 +11,57 @@ This library provides tools to help write tests for code that uses the following
11
11
12
12
#### On your machine
13
13
14
-
You can test against a temporary local datastore by following these steps:
14
+
You can test against a temporary local Datastore by following these steps:
15
15
16
-
1. Start the local datastore emulator using `LocalGcdHelper`. This can be done in two ways:
17
-
- Run `LocalGcdHelper.java`'s `main` method with `START` provided as an argument, followed by optional arguments `--port=<port number>` and `--consistency=<float between 0 and 1, inclusive>`. This will create a temporary folder on your computer and bind `localhost:<port number>` for communication with the local datastore. If no port number is specified, port 8080 will be used. The consistency setting controls the fraction of Datastore writes that are immediately visible in global queries.
18
-
- Use the `LocalGcdHelper.start(String projectId, int port, double consistency)` method before running your tests. For example, you can use the following code to start the local Datastore on any available port with the consistency set to 0.9:
19
-
```java
20
-
int port =LocalGcdHelper.findAvailablePort(LocalGcdHelper.DEFAULT_PORT);
1. Start the local Datastore emulator before running your tests using `LocalDatastoreHelper`'s `start` method. This will create a temporary folder on your computer and bind a port for communication with the local datastore. There are two optional arguments for `start`: project ID and consistency. The consistency setting controls the fraction of Datastore writes that are immediately visible in global queries.
- If you ran `LocalGcdHelper.java`'s `main` function to start the emulator, run `LocalGcdHelper.java`'s `main` method with arguments `STOP` and (optionally) `--port=<port number>`. If the port is not supplied, the program will attempt to close the last port started.
32
-
- If you ran the `LocalGcdHelper.start` method to start the emulator, call the `stop()` method on the `LocalGcdHelper` object returned by `LocalGcdHelper.start`.
31
+
4. Stop the local datastore emulator by calling the `stop()` method, like so:
32
+
```java
33
+
helper.stop();
34
+
```
33
35
34
36
#### On a remote machine
35
37
36
-
You can test against a remote datastore emulator as well. To do this, set the `DatastoreOptions` project endpoint to the hostname of the remote machine, like the example below.
38
+
You can test against a remote Datastore emulator as well. To do this, set the `DatastoreOptions` project endpoint to the hostname of the remote machine, like the example below.
Note that the remote datastore must be running before your tests are run.
48
+
Note that the remote Datastore emulator must be running before your tests are run.
48
49
49
50
### Testing code that uses Storage
50
51
51
-
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:
52
+
Currently, there isn't an emulator for Google Cloud Storage, so an alternative is to create a test project. `RemoteStorageHelper` contains convenience methods to make setting up and cleaning up the test project easier. To use this class, follow the steps below:
52
53
53
54
1. Create a test Google Cloud project.
54
55
55
56
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].
56
57
57
-
3. Create a `RemoteGcsHelper` object using your project ID and JSON key.
58
-
Here is an example that uses the `RemoteGcsHelper` to create a bucket.
58
+
3. Create a `RemoteStorageHelper` object using your project ID and JSON key.
59
+
Here is an example that uses the `RemoteStorageHelper` to create a bucket.
0 commit comments