UNPKG

@testcontainers/gcloud

Version:
50 lines 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StartedBigQueryEmulatorContainer = exports.BigQueryEmulatorContainer = void 0; const testcontainers_1 = require("testcontainers"); const EMULATOR_PORT = 9050; class BigQueryEmulatorContainer extends testcontainers_1.GenericContainer { _projectId; constructor(image) { super(image); this.withExposedPorts(EMULATOR_PORT).withWaitStrategy(testcontainers_1.Wait.forListeningPorts()).withStartupTimeout(120_000); // The BigQuery emulator image is not multi platform // so this fix is needed for ARM architectures if (process.arch === "arm64") { this.withPlatform("linux/amd64"); } } withProjectId(projectId) { this._projectId = projectId; return this; } async start() { // project flag is required, and corresponds to the projectId variable const projectId = this._projectId ?? "test-project"; this.withCommand(["--project", projectId]); return new StartedBigQueryEmulatorContainer(await super.start(), projectId); } } exports.BigQueryEmulatorContainer = BigQueryEmulatorContainer; class StartedBigQueryEmulatorContainer extends testcontainers_1.AbstractStartedContainer { projectId; constructor(startedTestContainer, projectId) { super(startedTestContainer); this.projectId = projectId; } /** * @return a <code>http://host:port</code> pair corresponding to the address on which the emulator is * reachable from the test host machine. */ getEmulatorEndpoint() { return `http://${this.getHost()}:${this.getMappedPort(EMULATOR_PORT)}`; } /** * @returns the project ID associated with the emulator. */ getProjectId() { return this.projectId; } } exports.StartedBigQueryEmulatorContainer = StartedBigQueryEmulatorContainer; //# sourceMappingURL=bigquery-emulator-container.js.map