exthos
Version:
stream processing in nodejs using the power of golang
30 lines • 1.4 kB
JavaScript
import EventEmitter2 from "eventemitter2";
import { Engine } from "./engine.js";
describe("engine start stop", () => {
let engine = new Engine({}, { keepAlive: false });
engine.onAny((eventName, eventObj) => {
if (eventName === "engine.fatal") {
throw new Error(eventObj["msg"] ||
"engine.fatal occured, but msg was absent in the eventObj.msg");
}
});
engine.updateEngineConfigs({
logger: { level: "NONE", format: "json" },
});
test("start and stop engine when benthos exe exists", async () => {
expect.assertions(2);
await expect(engine.start()).resolves.not.toThrow();
await expect(engine.stop()).resolves.not.toThrow();
}, 5 * 60 * 1000);
test("stop engine that hasnt started", async () => {
expect.assertions(1);
await expect(engine.stop()).resolves.not.toThrow();
}, engine.waitForActiveEventMs + 5000);
test("start engine that stops itself after 10s", async () => {
expect.assertions(2);
await expect(engine.start()).resolves.not.toThrow();
let eventObj = (await EventEmitter2.once(engine, engine.engineEvents["engine.inactive"]))[0];
expect(eventObj).toHaveProperty(["msg"], "stopped successfully. reason:no streams for the last 10000ms");
}, engine.waitForActiveEventMs + 11000);
});
//# sourceMappingURL=engine.test.js.map