Skip to content

Commit 83ba5b1

Browse files
committed
test(fixtures): rename single-letter fixture placeholders to descriptive fakes
1 parent 87ab176 commit 83ba5b1

3 files changed

Lines changed: 37 additions & 29 deletions

File tree

test/define-guarded.test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { defineGuardedPlugin } from '../.config/repo/rolldown/define-guarded.mts
1515
// Exported `function` declaration: satisfies both fleet rules —
1616
// socket/prefer-function-declaration (no module-scope arrow) and
1717
// socket/export-top-level-functions (top-level functions must be exported).
18-
export function run(code: string, id = 'src/x.ts'): string | undefined {
18+
export function run(code: string, id = 'src/example.ts'): string | undefined {
1919
const plugin = defineGuardedPlugin({
2020
'process.env.INLINED_EXTENSION_VERSION': JSON.stringify('2.0.3'),
2121
})
@@ -60,7 +60,7 @@ describe('defineGuardedPlugin', () => {
6060
test('parses .tsx source', () => {
6161
const out = run(
6262
'const e = <div>{process.env["INLINED_EXTENSION_VERSION"]}</div>',
63-
'src/x.tsx',
63+
'src/example.tsx',
6464
)
6565
expect(out).toContain('"2.0.3"')
6666
})

test/scripts/install-claude-plugins.test.mts

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,26 @@ const OUR = 'socket-wheelhouse'
2727

2828
test('extractInstalledSha returns 12-char prefix for SHA-pinned cache path', () => {
2929
const got = extractInstalledSha(
30-
'/Users/x/.claude/plugins/cache/socket-wheelhouse/codex/9cb4fe409919-deadbeef',
30+
'/Users/<user>/.claude/plugins/cache/socket-wheelhouse/codex/9cb4fe409919-deadbeef',
3131
)
3232
expect(got).toBe('9cb4fe409919')
3333
})
3434

3535
test('extractInstalledSha handles content-hash of various lengths', () => {
36-
const got = extractInstalledSha('/x/cache/m/p/abcdef012345-fedcba98')
36+
const got = extractInstalledSha(
37+
'/cache/marketplace/plugins/abcdef012345-fedcba98',
38+
)
3739
expect(got).toBe('abcdef012345')
3840
})
3941

4042
test('extractInstalledSha returns undefined for directory-source install (version-tagged)', () => {
41-
const got = extractInstalledSha('/Users/x/projects/codex-plugin-cc')
43+
const got = extractInstalledSha('/Users/<user>/projects/codex-plugin-cc')
4244
expect(got).toBe(undefined)
4345
})
4446

4547
test('extractInstalledSha returns undefined for version-tagged install', () => {
4648
const got = extractInstalledSha(
47-
'/Users/x/.claude/plugins/cache/openai-codex/codex/1.0.1',
49+
'/Users/<user>/.claude/plugins/cache/openai-codex/codex/1.0.1',
4850
)
4951
expect(got).toBe(undefined)
5052
})
@@ -59,15 +61,17 @@ test('extractInstalledSha returns undefined for empty string', () => {
5961

6062
test('extractInstalledSha rejects shapes that almost-match but are not 12 + 8+', () => {
6163
// 11 chars instead of 12.
62-
expect(extractInstalledSha('/x/cache/m/p/9cb4fe40991-deadbeef')).toBe(
63-
undefined,
64-
)
64+
expect(
65+
extractInstalledSha('/cache/marketplace/plugins/9cb4fe40991-deadbeef'),
66+
).toBe(undefined)
6567
// No content-hash suffix.
66-
expect(extractInstalledSha('/x/cache/m/p/9cb4fe409919')).toBe(undefined)
67-
// Non-hex chars.
68-
expect(extractInstalledSha('/x/cache/m/p/zzzzzzzzzzzz-deadbeef')).toBe(
68+
expect(extractInstalledSha('/cache/marketplace/plugins/9cb4fe409919')).toBe(
6969
undefined,
7070
)
71+
// Non-hex chars.
72+
expect(
73+
extractInstalledSha('/cache/marketplace/plugins/zzzzzzzzzzzz-deadbeef'),
74+
).toBe(undefined)
7175
})
7276

7377
const fakePlugin = (
@@ -82,7 +86,7 @@ const fakePlugin = (
8286

8387
test('findForeignInstall finds plugin under non-canonical marketplace', () => {
8488
const plugins = [
85-
fakePlugin('codex@openai-codex', '/Users/x/projects/codex-plugin-cc'),
89+
fakePlugin('codex@openai-codex', '/Users/<user>/projects/codex-plugin-cc'),
8690
fakePlugin('clangd-lsp@claude-plugins-official'),
8791
]
8892
const got = findForeignInstall('codex', plugins, OUR)
@@ -93,7 +97,7 @@ test('findForeignInstall returns undefined when plugin is under our marketplace'
9397
const plugins = [
9498
fakePlugin(
9599
'codex@socket-wheelhouse',
96-
'/x/cache/socket-wheelhouse/codex/9cb4fe409919-aa',
100+
'/cache/example/socket-wheelhouse/codex/9cb4fe409919-aa',
97101
),
98102
]
99103
const got = findForeignInstall('codex', plugins, OUR)
@@ -189,7 +193,7 @@ test('lookupInstalledSha extracts gitCommitSha from installed_plugins.json shape
189193
'codex@socket-wheelhouse': [
190194
{
191195
scope: 'user',
192-
installPath: '/x/y/z',
196+
installPath: '/home/<user>/install',
193197
version: '1.0.1',
194198
gitCommitSha: FULL_SHA,
195199
},
@@ -209,7 +213,11 @@ test('lookupInstalledSha returns undefined when entry has no gitCommitSha', () =
209213
version: 2,
210214
plugins: {
211215
'codex@socket-wheelhouse': [
212-
{ scope: 'user', installPath: '/x/y/z', version: '1.0.1' },
216+
{
217+
scope: 'user',
218+
installPath: '/home/<user>/install',
219+
version: '1.0.1',
220+
},
213221
],
214222
},
215223
}
@@ -322,14 +330,14 @@ test('stripPatchHeader only matches --- at line start (not mid-line)', () => {
322330
})
323331

324332
test('patchSidecarDir maps <x>.patch → <x>.files', () => {
325-
expect(patchSidecarDir('/a/b/codex-1.0.1-stdin-eagain.patch')).toBe(
326-
'/a/b/codex-1.0.1-stdin-eagain.files',
327-
)
333+
expect(
334+
patchSidecarDir('/home/<user>/build/codex-1.0.1-stdin-eagain.patch'),
335+
).toBe('/home/<user>/build/codex-1.0.1-stdin-eagain.files')
328336
})
329337

330338
test('patchSidecarDir only rewrites a trailing .patch extension', () => {
331339
// A `.patch` mid-path must not be rewritten — only the final extension.
332-
expect(patchSidecarDir('/a/.patch-stuff/codex-1.0.1-x.patch')).toBe(
333-
'/a/.patch-stuff/codex-1.0.1-x.files',
340+
expect(patchSidecarDir('/home/<user>/.patch-stuff/codex-1.0.1-x.patch')).toBe(
341+
'/home/<user>/.patch-stuff/codex-1.0.1-x.files',
334342
)
335343
})

test/select-artifacts.test.mts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ describe('worstArtifactsByPurl', () => {
8282
})
8383

8484
test('keeps each distinct PURL independently', () => {
85-
const purlA = 'pkg:pypi/a' as SimPURL
86-
const purlB = 'pkg:pypi/b' as SimPURL
87-
const aLow = makeArtifact(purlA, 0.1)
88-
const aHigh = makeArtifact(purlA, 0.9)
89-
const bOnly = makeArtifact(purlB, 0.7)
90-
const result = worstArtifactsByPurl([aHigh, bOnly, aLow])
85+
const purlExample = 'pkg:pypi/example' as SimPURL
86+
const purlOther = 'pkg:pypi/other' as SimPURL
87+
const exampleLow = makeArtifact(purlExample, 0.1)
88+
const exampleHigh = makeArtifact(purlExample, 0.9)
89+
const otherOnly = makeArtifact(purlOther, 0.7)
90+
const result = worstArtifactsByPurl([exampleHigh, otherOnly, exampleLow])
9191
expect(result.size).toBe(2)
92-
expect(result.get(purlA)).toBe(aLow)
93-
expect(result.get(purlB)).toBe(bOnly)
92+
expect(result.get(purlExample)).toBe(exampleLow)
93+
expect(result.get(purlOther)).toBe(otherOnly)
9494
})
9595

9696
test('returns an empty map for no entries', () => {

0 commit comments

Comments
 (0)