mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 12:27:40 +00:00
refactor(test): dedupe gateway env restores
This commit is contained in:
@@ -11,17 +11,13 @@ installGatewayTestHooks({ scope: "suite" });
|
||||
async function withServer<T>(
|
||||
run: (ws: Awaited<ReturnType<typeof startServerWithClient>>["ws"]) => Promise<T>,
|
||||
) {
|
||||
const { server, ws, prevToken } = await startServerWithClient("secret");
|
||||
const { server, ws, envSnapshot } = await startServerWithClient("secret");
|
||||
try {
|
||||
return await run(ws);
|
||||
} finally {
|
||||
ws.close();
|
||||
await server.close();
|
||||
if (prevToken === undefined) {
|
||||
delete process.env.OPENCLAW_GATEWAY_TOKEN;
|
||||
} else {
|
||||
process.env.OPENCLAW_GATEWAY_TOKEN = prevToken;
|
||||
}
|
||||
envSnapshot.restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user