dockest
Version:
Dockest is an integration testing tool aimed at alleviating the process of evaluating unit tests whilst running multi-container Docker applications.
28 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.zeroExitCodeReadinessCheck = void 0;
const rxjs_1 = require("rxjs");
const operators_1 = require("rxjs/operators");
const errors_1 = require("../errors");
const create_docker_event_emitter_1 = require("../run/bootstrap/create-docker-event-emitter");
/**
* A readiness check that succeeds when the service exits with the exit code 0.
*/
const zeroExitCodeReadinessCheck = (args) => (0, rxjs_1.race)(args.runner.dockerEventStream$.pipe((0, operators_1.filter)(create_docker_event_emitter_1.isDieEvent), (0, operators_1.map)((event) => {
if (event.attributes.exitCode !== '0') {
throw new errors_1.DockestError(`Container exited with the wrong exit code '${event.attributes.exitCode}'.`, {
runner: args.runner,
event,
});
}
return event;
}), (0, operators_1.mapTo)(undefined),
// complete stream (promise) after first successful health_status event was emitted.
(0, operators_1.take)(1)), args.runner.dockerEventStream$.pipe((0, operators_1.filter)(create_docker_event_emitter_1.isKillEvent), (0, operators_1.map)((event) => {
throw new errors_1.DockestError(`Received kill event.`, {
runner: args.runner,
event,
});
})));
exports.zeroExitCodeReadinessCheck = zeroExitCodeReadinessCheck;
//# sourceMappingURL=zero-exit-code-readiness-check.js.map