test: guard plugin services mock call

This commit is contained in:
Peter Steinberger
2026-05-12 05:41:13 +01:00
parent 7624b0d16d
commit ed6db3cd23

View File

@@ -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"],
]);