mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 08:21:39 -06:00
27 lines
776 B
TypeScript
27 lines
776 B
TypeScript
import { mkdir, mkdtemp, rm } from 'fs/promises';
|
|
import { tmpdir } from 'os';
|
|
import { join } from 'path';
|
|
|
|
export interface UsersAdminLifecycleFixtureRoot {
|
|
rootPath: string;
|
|
booksPath: string;
|
|
bookBucketPath: string;
|
|
cleanup: () => Promise<void>;
|
|
}
|
|
|
|
export async function createUsersAdminLifecycleFixtureRoot(prefix = 'users-admin-lifecycle-e2e-'): Promise<UsersAdminLifecycleFixtureRoot> {
|
|
const rootPath = await mkdtemp(join(tmpdir(), prefix));
|
|
const booksPath = join(rootPath, 'books');
|
|
const bookBucketPath = join(booksPath, 'book-bucket');
|
|
await mkdir(bookBucketPath, { recursive: true });
|
|
|
|
return {
|
|
rootPath,
|
|
booksPath,
|
|
bookBucketPath,
|
|
cleanup: async () => {
|
|
await rm(rootPath, { recursive: true, force: true });
|
|
},
|
|
};
|
|
}
|