UNPKG

dockest

Version:

Dockest is an integration testing tool aimed at alleviating the process of evaluating unit tests whilst running multi-container Docker applications.

22 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveContainerId = void 0; const rxjs_1 = require("rxjs"); const operators_1 = require("rxjs/operators"); const errors_1 = require("../../errors"); const LOG_PREFIX = '[Resolve Container Id]'; const DEFAULT_TIMEOUT = 30; const resolveContainerId = async ({ runner }) => { return (0, rxjs_1.race)(runner.dockerEventStream$.pipe((0, operators_1.first)((event) => event.action === 'start'), (0, operators_1.tap)(({ id: containerId }) => { runner.logger.info(`${LOG_PREFIX} Success (${containerId})`, { success: true }); runner.containerId = containerId; })), (0, rxjs_1.interval)(1000).pipe((0, operators_1.tap)((i) => { runner.logger.info(`Still waiting for start event... Timeout in ${DEFAULT_TIMEOUT - i}s`); }), (0, operators_1.skipWhile)((i) => i < DEFAULT_TIMEOUT), (0, operators_1.map)(() => { throw new errors_1.DockestError('Timed out', { runner }); }))) .pipe((0, operators_1.take)(1)) .toPromise(); }; exports.resolveContainerId = resolveContainerId; //# sourceMappingURL=resolve-container-id.js.map