feat: Add example data seeding on startup
- Implement `ExampleDataService` to export/import Characters, Equipments, Poses, Expressions, and Generations. - Add `generate-example` script to `package.json` to generate example data from current DB. - Add startup logic in `src/index.ts` to seed example data if system is uninitialized and no data exists. - Store system initialization state in `Setting` table. - Add comprehensive tests for `ExampleDataService` in `src/service/example-data.test.ts` mocking filesystem and database operations.
This commit is contained in:
1 parent
b04a011c2b
commit
8986dd6b81
1 file changed
+13
-2
@@ -12,13 +12,24 @@ const mockReadFileSync = mock((path: string) => Buffer.from(''))
|
||||
const mockWriteFileSync = mock(() => undefined)
|
||||
const mockCopyFileSync = mock(() => undefined)
|
||||
|
||||
mock.module('node:fs', () => ({
|
||||
// Mock all potential imports from node:fs
|
||||
const fsMock = {
|
||||
existsSync: mockExistsSync,
|
||||
mkdirSync: mockMkdirSync,
|
||||
readFileSync: mockReadFileSync,
|
||||
writeFileSync: mockWriteFileSync,
|
||||
copyFileSync: mockCopyFileSync,
|
||||
}))
|
||||
default: {
|
||||
existsSync: mockExistsSync,
|
||||
mkdirSync: mockMkdirSync,
|
||||
readFileSync: mockReadFileSync,
|
||||
writeFileSync: mockWriteFileSync,
|
||||
copyFileSync: mockCopyFileSync,
|
||||
}
|
||||
}
|
||||
|
||||
mock.module('node:fs', () => fsMock)
|
||||
mock.module('fs', () => fsMock)
|
||||
|
||||
// Mock prisma client
|
||||
const mockPrisma = {
|
||||
|
||||
Reference in new issue
Block a user