From 6c2573e37a4cce0de9f5009deed42d7839c210fb Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 4 May 2026 07:10:13 -0700 Subject: [PATCH] test(anthropic-vertex): accept native ADC home paths --- extensions/anthropic-vertex/region.adc.test.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/extensions/anthropic-vertex/region.adc.test.ts b/extensions/anthropic-vertex/region.adc.test.ts index 8a9d44d8a3b..1146f1491c8 100644 --- a/extensions/anthropic-vertex/region.adc.test.ts +++ b/extensions/anthropic-vertex/region.adc.test.ts @@ -1,3 +1,5 @@ +import { platform } from "node:os"; +import path from "node:path"; import { afterEach, describe, expect, it, vi } from "vitest"; const { existsSyncMock, readFileSyncMock } = vi.hoisted(() => ({ @@ -48,12 +50,17 @@ describe("anthropic-vertex ADC reads", () => { }); it("respects HOME when probing the default ADC path from a copied env snapshot", () => { + const homeDir = "/tmp/vertex-home"; + const defaultAdcPath = + platform() === "win32" + ? path.join(homeDir, "AppData", "Roaming", "gcloud", "application_default_credentials.json") + : path.join(homeDir, ".config", "gcloud", "application_default_credentials.json"); const env = { - HOME: "/tmp/vertex-home", + HOME: homeDir, } as NodeJS.ProcessEnv; readFileSyncMock.mockImplementation((pathname, options) => - String(pathname) === "/tmp/vertex-home/.config/gcloud/application_default_credentials.json" + String(pathname) === defaultAdcPath ? '{"project_id":"vertex-project"}' : String(pathname) === "/tmp/vertex-adc.json" ? '{"project_id":"vertex-project"}' @@ -65,9 +72,6 @@ describe("anthropic-vertex ADC reads", () => { expect(resolveAnthropicVertexProjectId(env)).toBe("vertex-project"); expect(hasAnthropicVertexAvailableAuth(env)).toBe(true); expect(existsSyncMock).not.toHaveBeenCalled(); - expect(readFileSyncMock).toHaveBeenCalledWith( - "/tmp/vertex-home/.config/gcloud/application_default_credentials.json", - "utf8", - ); + expect(readFileSyncMock).toHaveBeenCalledWith(defaultAdcPath, "utf8"); }); });