|
1 | 1 | // Qa Lab tests cover docker harness plugin behavior. |
2 | | -import { mkdtemp, readFile, rm } from "node:fs/promises"; |
| 2 | +import { mkdir, mkdtemp, readFile, rm } from "node:fs/promises"; |
3 | 3 | import os from "node:os"; |
4 | 4 | import path from "node:path"; |
5 | 5 | import { afterEach, describe, expect, it } from "vitest"; |
@@ -19,6 +19,7 @@ function parseComposeServices(compose: string) {
|
19 | 19 | services?: Record< |
20 | 20 | string, |
21 | 21 | { |
| 22 | +build?: { context?: string }; |
22 | 23 | environment?: Record<string, string>; |
23 | 24 | volumes?: string[]; |
24 | 25 | } |
@@ -156,4 +157,32 @@ describe("qa docker harness", () => {
|
156 | 157 | "docker build -t openclaw:qa-local-prebaked --build-arg OPENCLAW_EXTENSIONS=qa-channel qa-lab -f Dockerfile . @/repo/openclaw", |
157 | 158 | ]); |
158 | 159 | }); |
| 160 | + |
| 161 | +it("quotes generated compose paths so shell-sensitive repo paths survive YAML parsing", async () => { |
| 162 | +const tempRoot = await mkdtemp(path.join(os.tmpdir(), "qa-docker-paths-")); |
| 163 | +const outputDir = path.join(tempRoot, "scaffold"); |
| 164 | +const repoRoot = path.join(tempRoot, "repo #hash"); |
| 165 | +cleanups.push(async () => { |
| 166 | +await rm(tempRoot, { recursive: true, force: true }); |
| 167 | +}); |
| 168 | +await mkdir(repoRoot, { recursive: true }); |
| 169 | + |
| 170 | +await writeQaDockerHarnessFiles({ |
| 171 | + outputDir, |
| 172 | + repoRoot, |
| 173 | +gatewayToken: "qa-token", |
| 174 | +usePrebuiltImage: false, |
| 175 | +bindUiDist: true, |
| 176 | +}); |
| 177 | + |
| 178 | +const compose = await readFile(path.join(outputDir, "docker-compose.qa.yml"), "utf8"); |
| 179 | +const services = parseComposeServices(compose); |
| 180 | +expect(services["qa-mock-openai"]?.build?.context).toBe("../repo #hash"); |
| 181 | +expect(services["qa-lab"]?.volumes).toContain( |
| 182 | +"../repo #hash/extensions/qa-lab/web/dist:/opt/openclaw-qa-lab-ui:ro", |
| 183 | +); |
| 184 | +expect(services["openclaw-qa-gateway"]?.volumes).toContain( |
| 185 | +"../repo #hash:/opt/openclaw-repo:ro", |
| 186 | +); |
| 187 | +}); |
159 | 188 | }); |