File tree Expand file tree Collapse file tree
src/gateway/server-methods Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import { jsonResult } from "../../agents/tools/common.js";
88import type { ChannelPlugin } from "../../channels/plugins/types.js" ;
99import { setActivePluginRegistry } from "../../plugins/runtime.js" ;
1010import { createTestRegistry } from "../../test-utils/channel-plugins.js" ;
11+ import { captureEnv , setTestEnvValue } from "../../test-utils/env.js" ;
1112import type { GatewayRequestContext } from "./types.js" ;
1213
1314type ResolveOutboundTarget = typeof import ( "../../infra/outbound/targets.js" ) . resolveOutboundTarget ;
@@ -213,17 +214,13 @@ async function runMessageActionRequest(
213214}
214215
215216async function withTempOpenClawStateDir < T > ( test : ( stateDir : string ) => Promise < T > ) : Promise < T > {
216- const previous = process . env . OPENCLAW_STATE_DIR ;
217+ const envSnapshot = captureEnv ( [ " OPENCLAW_STATE_DIR" ] ) ;
217218 const stateDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "gateway-send-state-" ) ) ;
218- process . env . OPENCLAW_STATE_DIR = stateDir ;
219+ setTestEnvValue ( " OPENCLAW_STATE_DIR" , stateDir ) ;
219220 try {
220221 return await test ( stateDir ) ;
221222 } finally {
222- if ( previous === undefined ) {
223- delete process . env . OPENCLAW_STATE_DIR ;
224- } else {
225- process . env . OPENCLAW_STATE_DIR = previous ;
226- }
223+ envSnapshot . restore ( ) ;
227224 await fs . rm ( stateDir , { recursive : true , force : true } ) ;
228225 }
229226}
You can’t perform that action at this time.
0 commit comments