()
| 83 | let currentTestStore: Store | null = null; |
| 84 | |
| 85 | async function createTestStore(): Promise<Store> { |
| 86 | testDbPath = join(testDir, `test-${Date.now()}-${Math.random().toString(36).slice(2)}.sqlite`); |
| 87 | |
| 88 | // Set up test config directory |
| 89 | const configPrefix = join(testDir, `config-${Date.now()}-${Math.random().toString(36).slice(2)}`); |
| 90 | testConfigDir = await mkdtemp(configPrefix); |
| 91 | |
| 92 | // Set environment variable to use test config |
| 93 | process.env.QMD_CONFIG_DIR = testConfigDir; |
| 94 | |
| 95 | // Create empty YAML config |
| 96 | const emptyConfig: CollectionConfig = { collections: {} }; |
| 97 | await writeFile( |
| 98 | join(testConfigDir, "index.yml"), |
| 99 | YAML.stringify(emptyConfig) |
| 100 | ); |
| 101 | |
| 102 | const store = createStore(testDbPath); |
| 103 | currentTestStore = store; |
| 104 | return store; |
| 105 | } |
| 106 | |
| 107 | async function cleanupTestDb(store: Store): Promise<void> { |
| 108 | currentTestStore = null; |
no test coverage detected