Skip to content

Commit 93f8550

Browse files
Updates for new module tests
1 parent 4836bda commit 93f8550

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const IMAGE = getImage(__dirname, 3);
88
describe("SpannerEmulatorContainer", { timeout: 240_000 }, () => {
99
// startupWithExplicitClient {
1010
it("should start, expose endpoints and accept real client connections using explicitly configured client", async () => {
11-
const container = await new SpannerEmulatorContainer(IMAGE).withProjectId("test-project").start();
11+
await using container = await new SpannerEmulatorContainer(IMAGE).withProjectId("test-project").start();
1212

1313
const client = new Spanner({
1414
projectId: container.getProjectId(),
@@ -26,8 +26,6 @@ describe("SpannerEmulatorContainer", { timeout: 240_000 }, () => {
2626
// emulator always includes "emulator-config"
2727
const expectedConfigName = admin.instanceConfigPath(container.getProjectId(), "emulator-config");
2828
expect(configs.map((c) => c.name)).toContain(expectedConfigName);
29-
30-
await container.stop();
3129
});
3230
// }
3331

@@ -38,7 +36,7 @@ describe("SpannerEmulatorContainer", { timeout: 240_000 }, () => {
3836

3937
// startupWithEnvironmentVariable {
4038
it("should start, expose endpoints and accept real client connections using projectId and SPANNER_EMULATOR_HOST", async () => {
41-
const container = await new SpannerEmulatorContainer(IMAGE).withProjectId("test-project").start();
39+
await using container = await new SpannerEmulatorContainer(IMAGE).withProjectId("test-project").start();
4240

4341
// configure the client to talk to our emulator
4442
process.env.SPANNER_EMULATOR_HOST = container.getEmulatorGrpcEndpoint();
@@ -53,8 +51,6 @@ describe("SpannerEmulatorContainer", { timeout: 240_000 }, () => {
5351
// emulator always includes "emulator-config"
5452
const expectedConfigName = admin.instanceConfigPath(container.getProjectId(), "emulator-config");
5553
expect(configs.map((c) => c.name)).toContain(expectedConfigName);
56-
57-
await container.stop();
5854
});
5955
// }
6056
});

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const IMAGE = getImage(__dirname, 3);
88
describe("SpannerEmulatorHelper", { timeout: 240_000 }, () => {
99
// createAndDelete {
1010
it("should create and delete instance and database via helper", async () => {
11-
const container = await new SpannerEmulatorContainer(IMAGE).start();
11+
await using container = await new SpannerEmulatorContainer(IMAGE).start();
1212
const helper = new SpannerEmulatorHelper(container);
1313
const instanceId = "test-instance";
1414
const databaseId = "test-db";
@@ -37,8 +37,6 @@ describe("SpannerEmulatorHelper", { timeout: 240_000 }, () => {
3737

3838
const [instanceExistsAfter] = await client.instance(instanceId).exists();
3939
expect(instanceExistsAfter).toBe(false);
40-
41-
await container.stop();
4240
});
4341
// }
4442
});

packages/modules/vault/src/vault-container.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const IMAGE = getImage(__dirname);
88
describe("VaultContainer", { timeout: 180_000 }, () => {
99
// inside_block:readWrite {
1010
it("should start Vault and allow reading/writing secrets", async () => {
11-
const container = await new VaultContainer(IMAGE).withVaultToken(VAULT_TOKEN).start();
11+
await using container = await new VaultContainer(IMAGE).withVaultToken(VAULT_TOKEN).start();
1212

1313
const client = vault({
1414
apiVersion: "v1",
@@ -28,14 +28,12 @@ describe("VaultContainer", { timeout: 180_000 }, () => {
2828

2929
expect(data.message).toBe("world");
3030
expect(data.other).toBe("vault");
31-
32-
await container.stop();
3331
});
3432
// }
3533

3634
// inside_block:initCommands {
3735
it("should execute init commands using vault CLI", async () => {
38-
const container = await new VaultContainer(IMAGE)
36+
await using container = await new VaultContainer(IMAGE)
3937
.withVaultToken(VAULT_TOKEN)
4038
.withInitCommands("secrets enable transit", "write -f transit/keys/my-key")
4139
.start();
@@ -44,8 +42,6 @@ describe("VaultContainer", { timeout: 180_000 }, () => {
4442

4543
expect(result.exitCode).toBe(0);
4644
expect(result.output).toContain("my-key");
47-
48-
await container.stop();
4945
});
5046
// }
5147
});

0 commit comments

Comments
 (0)