@testcontainers/gcloud
Version:
GCloud module for Testcontainers
45 lines • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StartedPubSubEmulatorContainer = exports.PubSubEmulatorContainer = void 0;
const testcontainers_1 = require("testcontainers");
const abstract_gcloud_emulator_1 = require("./abstract-gcloud-emulator");
const EMULATOR_PORT = 8085;
class PubSubEmulatorContainer extends abstract_gcloud_emulator_1.AbstractGcloudEmulator {
projectId;
constructor(image) {
super(image, EMULATOR_PORT, "gcloud beta emulators pubsub start");
this.withWaitStrategy(testcontainers_1.Wait.forLogMessage(/Server started/g));
}
withProjectId(projectId) {
this.projectId = projectId;
return this;
}
async start() {
const selectedProjectId = this.projectId ?? "test-project";
this.withFlag("project", selectedProjectId);
return new StartedPubSubEmulatorContainer(await super.start(), selectedProjectId);
}
}
exports.PubSubEmulatorContainer = PubSubEmulatorContainer;
class StartedPubSubEmulatorContainer extends testcontainers_1.AbstractStartedContainer {
projectId;
constructor(startedTestContainer, projectId) {
super(startedTestContainer);
this.projectId = projectId;
}
/**
* @return a <code>host:port</code> pair corresponding to the address on which the emulator is
* reachable from the test host machine.
*/
getEmulatorEndpoint() {
return `${this.getHost()}:${this.getMappedPort(EMULATOR_PORT)}`;
}
/**
* @returns the project ID associated with the Pub/Sub emulator.
*/
getProjectId() {
return this.projectId;
}
}
exports.StartedPubSubEmulatorContainer = StartedPubSubEmulatorContainer;
//# sourceMappingURL=pubsub-emulator-container.js.map