test(hygiene): close every brain the vfs unit suite creates
Some checks are pending
CI / Node 22 (push) Waiting to run
CI / Node 24 (push) Waiting to run
CI / Integration + conformance (Node 22) (push) Waiting to run
CI / Bun (latest) (push) Waiting to run

Each file opened a Brainy per test (beforeEach) and never closed it.
This commit is contained in:
David Snelling 2026-09-03 09:06:13 -07:00
parent de79d6b5a4
commit be307a1579
3 changed files with 15 additions and 3 deletions

View file

@ -3,7 +3,7 @@
* Ensures tree methods prevent recursion and work correctly
*/
import { describe, it, expect, beforeEach } from 'vitest'
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { Brainy } from '../../src/brainy.js'
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
import { VFSTreeUtils } from '../../src/vfs/TreeUtils.js'
@ -24,6 +24,10 @@ describe('VFS Tree Operations', () => {
await vfs.init()
})
afterEach(async () => {
await brain.close()
})
describe('Critical: No Self-Inclusion Bug', () => {
it('should NEVER return a directory as its own child', async () => {
// Create test structure

View file

@ -6,7 +6,7 @@
* - Issue #2: File read decompression error
*/
import { describe, it, expect, beforeEach } from 'vitest'
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { Brainy } from '../../src/brainy.js'
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
@ -25,6 +25,10 @@ describe('VFS Bug Fixes', () => {
await vfs.init()
})
afterEach(async () => {
await brain.close()
})
describe('Issue #1: Duplicate Directory Nodes', () => {
it('should not create duplicate directory entries when writing multiple files to same directory', async () => {
// Write multiple files to the same directory (reproduce the bug scenario)

View file

@ -12,7 +12,7 @@
* other operations in parallel batches.
*/
import { describe, it, expect, beforeEach } from 'vitest'
import { describe, it, expect, beforeEach, afterEach } from 'vitest'
import { Brainy } from '../../src/brainy.js'
import { VirtualFileSystem } from '../../src/vfs/VirtualFileSystem.js'
@ -30,6 +30,10 @@ describe('VFS bulkWrite Race Condition Fix', () => {
await vfs.init()
})
afterEach(async () => {
await brain.close()
})
describe('operation ordering', () => {
it('should create directories before files when mixed in same batch', async () => {
// This is the exact scenario that triggered the race condition: