Skip to content

Commit bf92fce

Browse files
nzakasclaude
andcommitted
test: expect a suggestion rather than a fix for ADD to COPY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 259f5dc commit bf92fce

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

‎tests/autofix.test.ts‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,18 @@ describe("autofix", () => {
4444
);
4545
});
4646

47-
it("should convert ADD to COPY", () => {
47+
it("should suggest, not autofix, converting ADD to COPY", () => {
4848
const result = fix("ADD src/ /app/src/\n", {
4949
"docker/prefer-copy-over-add": "error",
5050
});
5151

52-
expect(result.output).toBe("COPY src/ /app/src/\n");
52+
expect(result.fixed).toBe(false);
53+
expect(result.output).toBe("ADD src/ /app/src/\n");
54+
expect(result.messages).toHaveLength(1);
55+
expect(result.messages[0]?.suggestions?.[0]?.fix).toEqual({
56+
range: [0, 3],
57+
text: "COPY",
58+
});
5359
});
5460

5561
it("should convert a lone RUN cd to WORKDIR", () => {
@@ -70,17 +76,10 @@ describe("autofix", () => {
7076

7177
it("should apply fixes from multiple rules at once", () => {
7278
const result = fix(
73-
[
74-
"from node:20",
75-
"maintainer jane",
76-
"add src/ /app/",
77-
"cmd npm start",
78-
"",
79-
].join("\n"),
79+
["from node:20", "maintainer jane", "cmd npm start", ""].join("\n"),
8080
{
8181
"docker/consistent-instruction-casing": "error",
8282
"docker/no-maintainer": "error",
83-
"docker/prefer-copy-over-add": "error",
8483
"docker/prefer-exec-form": "error",
8584
},
8685
);
@@ -90,7 +89,6 @@ describe("autofix", () => {
9089
[
9190
"FROM node:20",
9291
'LABEL maintainer="jane"',
93-
"COPY src/ /app/",
9492
'CMD ["npm", "start"]',
9593
"",
9694
].join("\n"),

0 commit comments

Comments
 (0)