Skip to content

Commit a198dcb

Browse files
committed
test: JS reference golden을 고정한다
1 parent 5922ede commit a198dcb

9 files changed

Lines changed: 151 additions & 0 deletions

File tree

‎test/fixtures/reference-env/.env‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
API_URL=http://localhost:3000
2+
AUTH_TOKEN=supersecretvalue12345
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "reference-tsconfig",
3+
"private": true
4+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"paths": {
5+
"@missing/*": ["ghost/*"]
6+
}
7+
}
8+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Maximus audit
2+
Target: <TARGET>
3+
4+
Status: clean
5+
Findings: 0 error, 0 warnings, 0 info
6+
Fixes available: 0
7+
8+
Structure: single package, 1 package(s), 1 config file(s), 0 env folder(s)
9+
10+
No config drift detected.
11+
12+
Recommendations
13+
- Current config surface looks healthy. Keep shared rules centralized as the repo grows.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Maximus doctor
2+
Target: <TARGET>
3+
4+
Diagnosis: clean
5+
Project shape: single package, 1 package(s), 1 config file(s), 0 env folder(s)
6+
7+
Prescription
8+
- No automatic fixes are currently available.
9+
- No manual follow-up is required right now.
10+
11+
No config drift detected.
12+
13+
Recommended structure
14+
- Current config surface looks healthy. Keep shared rules centralized as the repo grows.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Maximus audit
2+
Target: <TARGET>
3+
4+
Status: attention needed
5+
Findings: 0 error, 1 warnings, 0 info
6+
Fixes available: 1
7+
8+
Structure: single package, 0 package(s), 1 config file(s), 1 env folder(s)
9+
10+
Findings
11+
- [warn] Missing .env.example contract
12+
file: .env
13+
detail: Runtime env files exist, but .env.example is missing.
14+
hint: Run "maximus fix" to create a blank contract file.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Maximus fix
2+
Target: <TARGET>
3+
4+
Dry run: 1 safe fix(es) available.
5+
6+
Post-check: 0 error, 1 warnings, 0 info
7+
8+
Remaining findings
9+
- [warn] Missing .env.example contract
10+
file: .env
11+
detail: Runtime env files exist, but .env.example is missing.
12+
hint: Run "maximus fix" to create a blank contract file.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Maximus audit
2+
Target: <TARGET>
3+
4+
Status: blocking issues
5+
Findings: 1 error, 0 warnings, 0 info
6+
Fixes available: 0
7+
8+
Structure: single package, 1 package(s), 2 config file(s), 0 env folder(s)
9+
10+
Findings
11+
- [error] Path alias target does not exist
12+
file: tsconfig.json
13+
detail: @missing/* points to ghost/*, but the resolved path was not found.
14+
hint: Update or remove stale aliases before they break editor and build resolution.

‎test/reference-parity.test.js‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import assert from "node:assert/strict";
2+
import path from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
import test from "node:test";
5+
import { readFile } from "node:fs/promises";
6+
import { spawnSync } from "node:child_process";
7+
8+
const testDir = path.dirname(fileURLToPath(import.meta.url));
9+
const repoRoot = path.resolve(testDir, "..");
10+
11+
const scenarios = [
12+
{
13+
name: "clean-project audit output stays stable",
14+
args: ["audit", "./test/fixtures/clean-project"],
15+
goldenFile: "clean-project.audit.txt",
16+
expectedStatus: 0,
17+
targetDir: path.join(repoRoot, "test", "fixtures", "clean-project"),
18+
},
19+
{
20+
name: "clean-project doctor output stays stable",
21+
args: ["doctor", "./test/fixtures/clean-project"],
22+
goldenFile: "clean-project.doctor.txt",
23+
expectedStatus: 0,
24+
targetDir: path.join(repoRoot, "test", "fixtures", "clean-project"),
25+
},
26+
{
27+
name: "reference env audit output stays stable",
28+
args: ["audit", "./test/fixtures/reference-env"],
29+
goldenFile: "env-missing-example.audit.txt",
30+
expectedStatus: 1,
31+
targetDir: path.join(repoRoot, "test", "fixtures", "reference-env"),
32+
},
33+
{
34+
name: "reference env fix dry-run output stays stable",
35+
args: ["fix", "./test/fixtures/reference-env", "--dry-run"],
36+
goldenFile: "env-missing-example.fix-dry-run.txt",
37+
expectedStatus: 1,
38+
targetDir: path.join(repoRoot, "test", "fixtures", "reference-env"),
39+
},
40+
{
41+
name: "reference tsconfig audit output stays stable",
42+
args: ["audit", "./test/fixtures/reference-tsconfig"],
43+
goldenFile: "tsconfig-missing-alias.audit.txt",
44+
expectedStatus: 1,
45+
targetDir: path.join(repoRoot, "test", "fixtures", "reference-tsconfig"),
46+
},
47+
];
48+
49+
for (const scenario of scenarios) {
50+
test(scenario.name, async () => {
51+
const result = spawnSync(process.execPath, ["./bin/maximus.js", ...scenario.args], {
52+
cwd: repoRoot,
53+
encoding: "utf8",
54+
});
55+
56+
assert.equal(result.status, scenario.expectedStatus, result.stderr);
57+
58+
const actual = normalizeOutput(result.stdout, scenario.targetDir);
59+
const golden = normalizeOutput(
60+
await readFile(path.join(repoRoot, "test", "golden-rust", scenario.goldenFile), "utf8"),
61+
scenario.targetDir,
62+
);
63+
64+
assert.equal(actual, golden);
65+
});
66+
}
67+
68+
function normalizeOutput(output, targetDir) {
69+
return output.replaceAll("\r\n", "\n").replaceAll(targetDir, "<TARGET>").trimEnd();
70+
}

0 commit comments

Comments
 (0)