Skip to content

Commit 8af6be4

Browse files
committed
chore: wip
1 parent 59c60b3 commit 8af6be4

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

test/plugin-architecture.test.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
1010
let mockContext: SetupContext
1111
let originalEnv: Record<string, string | undefined>
1212
let originalCwd: string
13+
let tempDir: string
1314

1415
beforeEach(() => {
1516
// Store original working directory
1617
originalCwd = process.cwd()
17-
18+
1819
// Change to a temporary directory to avoid interference with project files
19-
const tempDir = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'plugin-test-'))
20+
// eslint-disable-next-line ts/no-require-imports
21+
tempDir = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'plugin-test-'))
2022
process.chdir(tempDir)
21-
23+
2224
pluginManager = new PluginManager()
2325
mockContext = {
2426
step: 'setup_complete',
@@ -93,13 +95,13 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
9395
fs.rmSync(file, { force: true })
9496
}
9597
})
96-
98+
9799
// Restore original working directory and clean up temp directory
98-
const tempDir = process.cwd()
99100
process.chdir(originalCwd)
100101
try {
101102
fs.rmSync(tempDir, { recursive: true, force: true })
102-
} catch {
103+
}
104+
catch {
103105
// Ignore cleanup errors
104106
}
105107

@@ -266,7 +268,20 @@ describe('Integration Ecosystem & Plugin Architecture', () => {
266268
}
267269

268270
const customPluginPath = path.join('.buddy/plugins', 'custom.json')
269-
fs.writeFileSync(customPluginPath, JSON.stringify(customPlugin))
271+
272+
// Ensure no composer.json exists in the test directory
273+
const composerPath = path.join(process.cwd(), 'composer.json')
274+
if (fs.existsSync(composerPath)) {
275+
fs.rmSync(composerPath, { force: true })
276+
}
277+
278+
// Write the file and ensure it's synced
279+
const pluginContent = JSON.stringify(customPlugin)
280+
fs.writeFileSync(customPluginPath, pluginContent)
281+
fs.fsyncSync(fs.openSync(customPluginPath, 'r'))
282+
283+
// Small delay to ensure file system operations complete
284+
await new Promise(resolve => setTimeout(resolve, 10))
270285

271286
// Verify the file was written correctly
272287
expect(fs.existsSync(customPluginPath)).toBe(true)

test/respect-latest.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ describe('respectLatest functionality', () => {
1414
// Create temporary test directory in a more isolated location
1515
// eslint-disable-next-line ts/no-require-imports
1616
testDir = fs.mkdtempSync(path.join(require('node:os').tmpdir(), 'buddy-test-'))
17+
18+
// Ensure the directory is truly isolated by checking it's empty
19+
const files = fs.readdirSync(testDir)
20+
if (files.length > 0) {
21+
console.log('🚨 Test directory not empty:', files)
22+
files.forEach(file => fs.rmSync(path.join(testDir, file), { recursive: true, force: true }))
23+
}
1724
})
1825

1926
afterEach(() => {
@@ -87,7 +94,19 @@ devDependencies:
8794
`
8895

8996
const depsPath = path.join(testDir, 'deps.yaml')
97+
98+
// Ensure no composer.json exists in the test directory
99+
const composerPath = path.join(testDir, 'composer.json')
100+
if (fs.existsSync(composerPath)) {
101+
fs.rmSync(composerPath, { force: true })
102+
}
103+
104+
// Write the file and ensure it's synced
90105
fs.writeFileSync(depsPath, depsYaml)
106+
fs.fsyncSync(fs.openSync(depsPath, 'r'))
107+
108+
// Small delay to ensure file system operations complete
109+
await new Promise(resolve => setTimeout(resolve, 10))
91110

92111
// Ensure the file was written correctly and verify content
93112
const actualFileContent = fs.readFileSync(depsPath, 'utf-8')

0 commit comments

Comments
 (0)