mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-12 06:00:25 +00:00
test: add coverage for cloud-init tier selection functions (#1958)
* test: add coverage for cloud-init tier selection functions getPackagesForTier, needsNode, and needsBun had zero test coverage despite non-trivial branching logic (4-way tier switch). Any change to package lists or tier membership would be silently undetected. Agent: test-engineer Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: format cloud-init.test.ts to pass biome format check Agent: team-lead Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
987a577fce
commit
266552b99f
1 changed files with 106 additions and 0 deletions
106
packages/cli/src/__tests__/cloud-init.test.ts
Normal file
106
packages/cli/src/__tests__/cloud-init.test.ts
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
import { describe, it, expect } from "bun:test";
|
||||
import { getPackagesForTier, needsNode, needsBun, NODE_INSTALL_CMD } from "../shared/cloud-init.js";
|
||||
|
||||
describe("getPackagesForTier", () => {
|
||||
const MINIMAL_PACKAGES = [
|
||||
"curl",
|
||||
"unzip",
|
||||
"git",
|
||||
"ca-certificates",
|
||||
];
|
||||
|
||||
it("returns minimal packages for 'minimal' tier", () => {
|
||||
const pkgs = getPackagesForTier("minimal");
|
||||
expect(pkgs).toEqual(MINIMAL_PACKAGES);
|
||||
});
|
||||
|
||||
it("returns minimal + zsh + build-essential for 'node' tier", () => {
|
||||
const pkgs = getPackagesForTier("node");
|
||||
for (const p of MINIMAL_PACKAGES) {
|
||||
expect(pkgs).toContain(p);
|
||||
}
|
||||
expect(pkgs).toContain("zsh");
|
||||
expect(pkgs).toContain("build-essential");
|
||||
});
|
||||
|
||||
it("returns minimal + zsh but NOT build-essential for 'bun' tier", () => {
|
||||
const pkgs = getPackagesForTier("bun");
|
||||
for (const p of MINIMAL_PACKAGES) {
|
||||
expect(pkgs).toContain(p);
|
||||
}
|
||||
expect(pkgs).toContain("zsh");
|
||||
expect(pkgs).not.toContain("build-essential");
|
||||
});
|
||||
|
||||
it("returns minimal + zsh + build-essential for 'full' tier", () => {
|
||||
const pkgs = getPackagesForTier("full");
|
||||
for (const p of MINIMAL_PACKAGES) {
|
||||
expect(pkgs).toContain(p);
|
||||
}
|
||||
expect(pkgs).toContain("zsh");
|
||||
expect(pkgs).toContain("build-essential");
|
||||
});
|
||||
|
||||
it("defaults to 'full' tier when no argument given", () => {
|
||||
expect(getPackagesForTier()).toEqual(getPackagesForTier("full"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("needsNode", () => {
|
||||
it("returns true for 'node' tier", () => {
|
||||
expect(needsNode("node")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns true for 'full' tier", () => {
|
||||
expect(needsNode("full")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false for 'minimal' tier", () => {
|
||||
expect(needsNode("minimal")).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for 'bun' tier", () => {
|
||||
expect(needsNode("bun")).toBe(false);
|
||||
});
|
||||
|
||||
it("defaults to true (full tier)", () => {
|
||||
expect(needsNode()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("needsBun", () => {
|
||||
it("returns true for 'bun' tier", () => {
|
||||
expect(needsBun("bun")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns true for 'full' tier", () => {
|
||||
expect(needsBun("full")).toBe(true);
|
||||
});
|
||||
|
||||
it("returns false for 'minimal' tier", () => {
|
||||
expect(needsBun("minimal")).toBe(false);
|
||||
});
|
||||
|
||||
it("returns false for 'node' tier", () => {
|
||||
expect(needsBun("node")).toBe(false);
|
||||
});
|
||||
|
||||
it("defaults to true (full tier)", () => {
|
||||
expect(needsBun()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("NODE_INSTALL_CMD", () => {
|
||||
it("is a non-empty string", () => {
|
||||
expect(typeof NODE_INSTALL_CMD).toBe("string");
|
||||
expect(NODE_INSTALL_CMD.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("installs Node 22", () => {
|
||||
expect(NODE_INSTALL_CMD).toContain("22");
|
||||
});
|
||||
|
||||
it("downloads and runs an install script", () => {
|
||||
expect(NODE_INSTALL_CMD).toContain("curl");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue