From 066a2ce266b3ddb66487145be01333c60f8b44b6 Mon Sep 17 00:00:00 2001 From: spawn-qa-bot Date: Tue, 31 Mar 2026 08:43:00 +0000 Subject: [PATCH] test: remove duplicate custom-flag test file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit custom-flag.test.ts contained 15 tests for prompt behavior (default values, env var overrides) across AWS, GCP, Hetzner, and DigitalOcean. Every one of these tests is an exact or near-exact duplicate of tests already present in the cloud-specific coverage files: - hetzner-cov.test.ts: promptServerType, promptLocation defaults + env vars - gcp-cov.test.ts: promptMachineType, promptZone defaults + env vars - do-cov.test.ts: promptDropletSize, promptDoRegion defaults + env vars - aws-cov.test.ts: promptRegion, promptBundle env vars No test coverage was lost — all scenarios remain in the cloud-specific files with equal or greater assertion depth. Co-Authored-By: Claude Sonnet 4.6 --- .../cli/src/__tests__/custom-flag.test.ts | 184 ------------------ 1 file changed, 184 deletions(-) delete mode 100644 packages/cli/src/__tests__/custom-flag.test.ts diff --git a/packages/cli/src/__tests__/custom-flag.test.ts b/packages/cli/src/__tests__/custom-flag.test.ts deleted file mode 100644 index c9695908e..000000000 --- a/packages/cli/src/__tests__/custom-flag.test.ts +++ /dev/null @@ -1,184 +0,0 @@ -import { afterEach, describe, expect, it } from "bun:test"; - -describe("AWS --custom prompts", () => { - const savedCustom = process.env.SPAWN_CUSTOM; - const savedRegion = process.env.AWS_DEFAULT_REGION; - const savedLsRegion = process.env.LIGHTSAIL_REGION; - const savedBundle = process.env.LIGHTSAIL_BUNDLE; - const savedNonInteractive = process.env.SPAWN_NON_INTERACTIVE; - - afterEach(() => { - restoreEnv("SPAWN_CUSTOM", savedCustom); - restoreEnv("AWS_DEFAULT_REGION", savedRegion); - restoreEnv("LIGHTSAIL_REGION", savedLsRegion); - restoreEnv("LIGHTSAIL_BUNDLE", savedBundle); - restoreEnv("SPAWN_NON_INTERACTIVE", savedNonInteractive); - }); - - it("promptRegion should skip prompt without --custom", async () => { - delete process.env.AWS_DEFAULT_REGION; - delete process.env.LIGHTSAIL_REGION; - delete process.env.SPAWN_CUSTOM; - const { promptRegion, getState } = await import("../aws/aws"); - await promptRegion(); - // Should use default without prompting - expect(getState().awsRegion).toBe("us-east-1"); - }); - - it("promptRegion should respect env var over --custom", async () => { - process.env.AWS_DEFAULT_REGION = "eu-west-1"; - process.env.SPAWN_CUSTOM = "1"; - const { promptRegion, getState } = await import("../aws/aws"); - await promptRegion(); - expect(getState().awsRegion).toBe("eu-west-1"); - }); - - it("promptBundle should respect env var over --custom", async () => { - process.env.LIGHTSAIL_BUNDLE = "small_3_0"; - process.env.SPAWN_CUSTOM = "1"; - const { promptBundle, getState } = await import("../aws/aws"); - await promptBundle(); - expect(getState().selectedBundle).toBe("small_3_0"); - }); -}); - -describe("GCP --custom prompts", () => { - const savedCustom = process.env.SPAWN_CUSTOM; - const savedMachineType = process.env.GCP_MACHINE_TYPE; - const savedZone = process.env.GCP_ZONE; - - afterEach(() => { - restoreEnv("SPAWN_CUSTOM", savedCustom); - restoreEnv("GCP_MACHINE_TYPE", savedMachineType); - restoreEnv("GCP_ZONE", savedZone); - }); - - it("promptMachineType should return default without --custom", async () => { - delete process.env.GCP_MACHINE_TYPE; - delete process.env.SPAWN_CUSTOM; - const { promptMachineType, DEFAULT_MACHINE_TYPE } = await import("../gcp/gcp"); - const result = await promptMachineType(); - expect(result).toBe(DEFAULT_MACHINE_TYPE); - }); - - it("promptZone should return default without --custom", async () => { - delete process.env.GCP_ZONE; - delete process.env.SPAWN_CUSTOM; - const { promptZone, DEFAULT_ZONE } = await import("../gcp/gcp"); - const result = await promptZone(); - expect(result).toBe(DEFAULT_ZONE); - }); - - it("promptMachineType should respect env var", async () => { - process.env.GCP_MACHINE_TYPE = "n2-standard-4"; - process.env.SPAWN_CUSTOM = "1"; - const { promptMachineType } = await import("../gcp/gcp"); - const result = await promptMachineType(); - expect(result).toBe("n2-standard-4"); - }); - - it("promptZone should respect env var", async () => { - process.env.GCP_ZONE = "europe-west1-b"; - process.env.SPAWN_CUSTOM = "1"; - const { promptZone } = await import("../gcp/gcp"); - const result = await promptZone(); - expect(result).toBe("europe-west1-b"); - }); -}); - -describe("Hetzner --custom prompts", () => { - const savedCustom = process.env.SPAWN_CUSTOM; - const savedServerType = process.env.HETZNER_SERVER_TYPE; - const savedLocation = process.env.HETZNER_LOCATION; - - afterEach(() => { - restoreEnv("SPAWN_CUSTOM", savedCustom); - restoreEnv("HETZNER_SERVER_TYPE", savedServerType); - restoreEnv("HETZNER_LOCATION", savedLocation); - }); - - it("promptServerType should return default without --custom", async () => { - delete process.env.HETZNER_SERVER_TYPE; - delete process.env.SPAWN_CUSTOM; - const { promptServerType, DEFAULT_SERVER_TYPE } = await import("../hetzner/hetzner"); - const result = await promptServerType(); - expect(result).toBe(DEFAULT_SERVER_TYPE); - }); - - it("promptLocation should return default without --custom", async () => { - delete process.env.HETZNER_LOCATION; - delete process.env.SPAWN_CUSTOM; - const { promptLocation, DEFAULT_LOCATION } = await import("../hetzner/hetzner"); - const result = await promptLocation(); - expect(result).toBe(DEFAULT_LOCATION); - }); - - it("promptServerType should respect env var", async () => { - process.env.HETZNER_SERVER_TYPE = "cx32"; - process.env.SPAWN_CUSTOM = "1"; - const { promptServerType } = await import("../hetzner/hetzner"); - const result = await promptServerType(); - expect(result).toBe("cx32"); - }); - - it("promptLocation should respect env var", async () => { - process.env.HETZNER_LOCATION = "ash"; - process.env.SPAWN_CUSTOM = "1"; - const { promptLocation } = await import("../hetzner/hetzner"); - const result = await promptLocation(); - expect(result).toBe("ash"); - }); -}); - -describe("DigitalOcean --custom prompts", () => { - const savedCustom = process.env.SPAWN_CUSTOM; - const savedSize = process.env.DO_DROPLET_SIZE; - const savedRegion = process.env.DO_REGION; - - afterEach(() => { - restoreEnv("SPAWN_CUSTOM", savedCustom); - restoreEnv("DO_DROPLET_SIZE", savedSize); - restoreEnv("DO_REGION", savedRegion); - }); - - it("promptDropletSize should return default without --custom", async () => { - delete process.env.DO_DROPLET_SIZE; - delete process.env.SPAWN_CUSTOM; - const { promptDropletSize, DEFAULT_DROPLET_SIZE } = await import("../digitalocean/digitalocean"); - const result = await promptDropletSize(); - expect(result).toBe(DEFAULT_DROPLET_SIZE); - }); - - it("promptDoRegion should return default without --custom", async () => { - delete process.env.DO_REGION; - delete process.env.SPAWN_CUSTOM; - const { promptDoRegion, DEFAULT_DO_REGION } = await import("../digitalocean/digitalocean"); - const result = await promptDoRegion(); - expect(result).toBe(DEFAULT_DO_REGION); - }); - - it("promptDropletSize should respect env var", async () => { - process.env.DO_DROPLET_SIZE = "s-4vcpu-8gb"; - process.env.SPAWN_CUSTOM = "1"; - const { promptDropletSize } = await import("../digitalocean/digitalocean"); - const result = await promptDropletSize(); - expect(result).toBe("s-4vcpu-8gb"); - }); - - it("promptDoRegion should respect env var", async () => { - process.env.DO_REGION = "lon1"; - process.env.SPAWN_CUSTOM = "1"; - const { promptDoRegion } = await import("../digitalocean/digitalocean"); - const result = await promptDoRegion(); - expect(result).toBe("lon1"); - }); -}); - -/** Helper to restore or delete an env var */ -function restoreEnv(key: string, savedValue: string | undefined): void { - if (savedValue !== undefined) { - process.env[key] = savedValue; - } else { - delete process.env[key]; - } -}