mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-20 05:07:34 +00:00
test: guard plugin services mock call
This commit is contained in:
@@ -78,6 +78,14 @@ function expectServiceLifecycleState(params: {
|
||||
expectServiceContexts(params.contexts, params.config);
|
||||
}
|
||||
|
||||
function requireLoggerErrorMessage(index = 0): string {
|
||||
const call = mockedLogger.error.mock.calls.at(index);
|
||||
if (!call) {
|
||||
throw new Error(`expected logger error call ${index}`);
|
||||
}
|
||||
return call[0];
|
||||
}
|
||||
|
||||
async function startTrackingServices(params: {
|
||||
services: OpenClawPluginService[];
|
||||
config?: Parameters<typeof startPluginServices>[0]["config"];
|
||||
@@ -174,7 +182,7 @@ describe("startPluginServices", () => {
|
||||
"plugin service failed (service-start-fail, plugin=plugin:test, root=/plugins/test-plugin): start failed",
|
||||
],
|
||||
]);
|
||||
expect(mockedLogger.error.mock.calls[0]?.[0]).not.toContain("\n");
|
||||
expect(requireLoggerErrorMessage()).not.toContain("\n");
|
||||
expect(mockedLogger.warn.mock.calls).toEqual([
|
||||
["plugin service stop failed (service-stop-fail): Error: stop failed"],
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user