fix: respect compose project name
This commit is contained in:
+22
-1
@@ -7,7 +7,7 @@ import {
|
||||
resolveComposeArch,
|
||||
withComposeArch,
|
||||
} from "../../lib/arch";
|
||||
import { createCachedGetter, ctx } from "../../lib/context";
|
||||
import { createCachedGetter, ctx, resolveProjectName } from "../../lib/context";
|
||||
import { toEnvVars, toTable } from "../../lib/format";
|
||||
import { deepMerge, getPodContainerName, throwWhen } from "../../lib/shared";
|
||||
|
||||
@@ -131,6 +131,27 @@ describe("shared helpers", () => {
|
||||
});
|
||||
|
||||
describe("context helpers", () => {
|
||||
test("resolves project names using config, Compose, then directory precedence", () => {
|
||||
expect(
|
||||
resolveProjectName(
|
||||
{ project: "directory", projectConfigured: false },
|
||||
{ name: "compose" },
|
||||
),
|
||||
).toBe("compose");
|
||||
expect(
|
||||
resolveProjectName(
|
||||
{ project: "config", projectConfigured: true },
|
||||
{ name: "compose" },
|
||||
),
|
||||
).toBe("config");
|
||||
expect(
|
||||
resolveProjectName(
|
||||
{ project: "directory", projectConfigured: false },
|
||||
{},
|
||||
),
|
||||
).toBe("directory");
|
||||
});
|
||||
|
||||
test("rejects access outside an application context", () => {
|
||||
expect(() => ctx()).toThrow("Not in context");
|
||||
});
|
||||
|
||||
@@ -50,8 +50,12 @@ describe("Compose parsing", () => {
|
||||
test("parses and validates a minimal Compose project", async () => {
|
||||
const directory = await temporaryDirectory();
|
||||
const path = join(directory, "compose.yml");
|
||||
await writeFile(path, "services:\n app:\n image: nginx:latest\n");
|
||||
await writeFile(
|
||||
path,
|
||||
"name: compose-project\nservices:\n app:\n image: nginx:latest\n",
|
||||
);
|
||||
expect(await readCompose(path)).toMatchObject({
|
||||
name: "compose-project",
|
||||
services: { app: { image: "nginx:latest" } },
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user