diff --git a/src/commands/gateway-status.e2e.test.ts b/src/commands/gateway-status.e2e.test.ts index 0746bac5f..b95c6e68a 100644 --- a/src/commands/gateway-status.e2e.test.ts +++ b/src/commands/gateway-status.e2e.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it, vi } from "vitest"; +import { withEnvAsync } from "../test-utils/env.js"; const loadConfig = vi.fn(() => ({ gateway: { @@ -133,16 +134,6 @@ function createRuntimeCapture() { return { runtime, runtimeLogs, runtimeErrors }; } -async function withUserEnv(user: string, fn: () => Promise) { - const originalUser = process.env.USER; - try { - process.env.USER = user; - await fn(); - } finally { - process.env.USER = originalUser; - } -} - describe("gateway-status command", () => { it("prints human output by default", async () => { const { runtime, runtimeLogs, runtimeErrors } = createRuntimeCapture(); @@ -206,7 +197,7 @@ describe("gateway-status command", () => { it("skips invalid ssh-auto discovery targets", async () => { const { runtime } = createRuntimeCapture(); - await withUserEnv("steipete", async () => { + await withEnvAsync({ USER: "steipete" }, async () => { loadConfig.mockReturnValueOnce({ gateway: { mode: "remote", @@ -234,7 +225,7 @@ describe("gateway-status command", () => { it("infers SSH target from gateway.remote.url and ssh config", async () => { const { runtime } = createRuntimeCapture(); - await withUserEnv("steipete", async () => { + await withEnvAsync({ USER: "steipete" }, async () => { loadConfig.mockReturnValueOnce({ gateway: { mode: "remote", @@ -268,7 +259,7 @@ describe("gateway-status command", () => { it("falls back to host-only when USER is missing and ssh config is unavailable", async () => { const { runtime } = createRuntimeCapture(); - await withUserEnv("", async () => { + await withEnvAsync({ USER: "" }, async () => { loadConfig.mockReturnValueOnce({ gateway: { mode: "remote",