MCPcopy
hub / github.com/tobi/qmd / createTestStore

Function createTestStore

test/store.test.ts:85–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83let currentTestStore: Store | null = null;
84
85async 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
107async function cleanupTestDb(store: Store): Promise<void> {
108 currentTestStore = null;

Callers 1

store.test.tsFile · 0.85

Calls 1

createStoreFunction · 0.50

Tested by

no test coverage detected