Skip to content

Commit a6bdcaa

Browse files
Gcloud
1 parent cbc5601 commit a6bdcaa

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

docs/modules/gcloud.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,25 @@ Choose an image from the [container registry](https://hub.docker.com/r/fsouza/fa
7676

7777
These examples use the following libraries:
7878

79-
- [@google-cloud/datastore](https://www.npmjs.com/package/@google-cloud/datastore)
79+
- [@google-cloud/spanner](https://www.npmjs.com/package/@google-cloud/spanner)
8080

81-
npm install @google-cloud/datastore
81+
npm install @google-cloud/spanner
8282

8383
Choose an image from the [container registry](https://gcr.io/cloud-spanner-emulator/emulator:1.5.37) and substitute `IMAGE`.
8484

85-
#### Default
86-
85+
#### Connect via client
86+
8787
<!--codeinclude-->
8888
[](../../packages/modules/gcloud/src/spanner-emulator-container.test.ts) inside_block:startupWithExplicitClient
8989
<!--/codeinclude-->
9090

91-
#### With environment variable
91+
#### Connect via environment
9292

9393
<!--codeinclude-->
9494
[](../../packages/modules/gcloud/src/spanner-emulator-container.test.ts) inside_block:startupWithEnvironmentVariable
9595
<!--/codeinclude-->
9696

97-
#### Helper
97+
#### Helper usage
9898

9999
<!--codeinclude-->
100100
[](../../packages/modules/gcloud/src/spanner-emulator-helper.test.ts) inside_block:createAndDelete

packages/modules/gcloud/src/spanner-emulator-container.test.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,47 @@ import { SpannerEmulatorContainer } from "./spanner-emulator-container";
66
const IMAGE = getImage(__dirname, 3);
77

88
describe("SpannerEmulatorContainer", { timeout: 240_000 }, () => {
9-
// startupWithExplicitClient {
109
it("should start, expose endpoints and accept real client connections using explicitly configured client", async () => {
10+
// startupWithExplicitClient {
1111
await using container = await new SpannerEmulatorContainer(IMAGE).withProjectId("test-project").start();
1212

13-
const client = new Spanner({
13+
const spanner = new Spanner({
1414
projectId: container.getProjectId(),
1515
apiEndpoint: container.getHost(),
1616
port: container.getGrpcPort(),
1717
sslCreds: container.getSslCredentials(),
1818
});
1919

20-
// list instance configs
21-
const admin = client.getInstanceAdminClient();
20+
const admin = spanner.getInstanceAdminClient();
2221
const [configs] = await admin.listInstanceConfigs({
2322
parent: admin.projectPath(container.getProjectId()),
2423
});
2524

26-
// emulator always includes "emulator-config"
2725
const expectedConfigName = admin.instanceConfigPath(container.getProjectId(), "emulator-config");
2826
expect(configs.map((c) => c.name)).toContain(expectedConfigName);
27+
// }
2928
});
30-
// }
3129

3230
describe.sequential("Shared state", () => {
3331
afterEach(() => {
3432
process.env.SPANNER_EMULATOR_HOST = "";
3533
});
3634

37-
// startupWithEnvironmentVariable {
3835
it("should start, expose endpoints and accept real client connections using projectId and SPANNER_EMULATOR_HOST", async () => {
3936
await using container = await new SpannerEmulatorContainer(IMAGE).withProjectId("test-project").start();
4037

41-
// configure the client to talk to our emulator
38+
// startupWithEnvironmentVariable {
4239
process.env.SPANNER_EMULATOR_HOST = container.getEmulatorGrpcEndpoint();
43-
const client = new Spanner({ projectId: container.getProjectId() });
40+
const spanner = new Spanner({ projectId: container.getProjectId() });
41+
// }
4442

45-
// list instance configs
46-
const admin = client.getInstanceAdminClient();
43+
const admin = spanner.getInstanceAdminClient();
4744
const [configs] = await admin.listInstanceConfigs({
4845
parent: admin.projectPath(container.getProjectId()),
4946
});
5047

51-
// emulator always includes "emulator-config"
5248
const expectedConfigName = admin.instanceConfigPath(container.getProjectId(), "emulator-config");
5349
expect(configs.map((c) => c.name)).toContain(expectedConfigName);
5450
});
55-
// }
5651
});
5752
});

packages/modules/gcloud/src/spanner-emulator-helper.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import { SpannerEmulatorHelper } from "./spanner-emulator-helper";
66
const IMAGE = getImage(__dirname, 3);
77

88
describe("SpannerEmulatorHelper", { timeout: 240_000 }, () => {
9-
// createAndDelete {
109
it("should create and delete instance and database via helper", async () => {
10+
// createAndDelete {
1111
await using container = await new SpannerEmulatorContainer(IMAGE).start();
12+
1213
const helper = new SpannerEmulatorHelper(container);
1314
const instanceId = "test-instance";
1415
const databaseId = "test-db";
@@ -37,6 +38,6 @@ describe("SpannerEmulatorHelper", { timeout: 240_000 }, () => {
3738

3839
const [instanceExistsAfter] = await client.instance(instanceId).exists();
3940
expect(instanceExistsAfter).toBe(false);
41+
// }
4042
});
41-
// }
4243
});

0 commit comments

Comments
 (0)