Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose getProjectId in DatastoreEmulatorContainer #7328

Merged
merged 1 commit into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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