|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { aptBase } from "../../src/toolchains/shared.js"; |
| 3 | +import { rust } from "../../src/toolchains/rust.js"; |
| 4 | +import { uv } from "../../src/toolchains/py/uv.js"; |
| 5 | +import { pipeline } from "../../src/pipeline.js"; |
| 6 | + |
| 7 | +describe("aptBase", () => { |
| 8 | + it("creates a step with apt-get install", () => { |
| 9 | + const base = aptBase({ packages: ["curl", "ca-certificates"] }); |
| 10 | + expect(base._cmd).toContain( |
| 11 | + "apt-get update && apt-get install -y curl ca-certificates", |
| 12 | + ); |
| 13 | + }); |
| 14 | + |
| 15 | + it("default label is :apt: base", () => { |
| 16 | + const base = aptBase({ packages: ["curl"] }); |
| 17 | + expect(base._label).toBe(":apt: base"); |
| 18 | + }); |
| 19 | + |
| 20 | + it("accepts custom label", () => { |
| 21 | + const base = aptBase({ packages: ["curl"], label: ":lock: deps" }); |
| 22 | + expect(base._label).toBe(":lock: deps"); |
| 23 | + }); |
| 24 | + |
| 25 | + it("shared across rust and python toolchains", () => { |
| 26 | + const base = aptBase({ |
| 27 | + packages: [ |
| 28 | + "curl", |
| 29 | + "ca-certificates", |
| 30 | + "build-essential", |
| 31 | + "pkg-config", |
| 32 | + "libssl-dev", |
| 33 | + "python3", |
| 34 | + "python3-venv", |
| 35 | + ], |
| 36 | + }); |
| 37 | + const r = rust({ base }); |
| 38 | + const p = uv({ path: "dsls/harmont-py", base }); |
| 39 | + const ir = pipeline(r.build(), p.test(), { defaultImage: "ubuntu:24.04" }); |
| 40 | + const cmds = ir.graph.nodes.map( |
| 41 | + (n: { step: { cmd: string } }) => n.step.cmd, |
| 42 | + ); |
| 43 | + const aptSteps = cmds.filter((c: string) => c.includes("apt-get install")); |
| 44 | + expect(aptSteps).toHaveLength(1); |
| 45 | + }); |
| 46 | +}); |
0 commit comments