Skip to content

Commit

Permalink
Expose getProjectId in DatastoreEmulatorContainer (#7328)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez committed Jul 24, 2023
1 parent a292a89 commit bd70f5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ public class DatastoreEmulatorContainer extends GenericContainer<DatastoreEmulat
"gcr.io/google.com/cloudsdktool/cloud-sdk"
);

private static final String CMD =
"gcloud beta emulators datastore start --project test-project --host-port 0.0.0.0:8081";
private static final String PROJECT_ID = "test-project";

private static final String CMD = String.format(
"gcloud beta emulators datastore start --project %s --host-port 0.0.0.0:8081",
PROJECT_ID
);

private static final int HTTP_PORT = 8081;

Expand Down Expand Up @@ -59,4 +63,8 @@ public DatastoreEmulatorContainer withFlags(String flags) {
public String getEmulatorEndpoint() {
return getHost() + ":" + getMappedPort(HTTP_PORT);
}

public String getProjectId() {
return PROJECT_ID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void testSimple() {
.setHost(emulator.getEmulatorEndpoint())
.setCredentials(NoCredentials.getInstance())
.setRetrySettings(ServiceOptions.getNoRetrySettings())
.setProjectId("test-project")
.setProjectId(emulator.getProjectId())
.build();
Datastore datastore = options.getService();

Expand Down

0 comments on commit bd70f5b

Please sign in to comment.