diff options
Diffstat (limited to 'database/factories/UserFactory.ts')
-rw-r--r-- | database/factories/UserFactory.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/database/factories/UserFactory.ts b/database/factories/UserFactory.ts new file mode 100644 index 0000000..ee6553e --- /dev/null +++ b/database/factories/UserFactory.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import User from 'App/Models/User'; | ||
2 | import Factory from '@ioc:Adonis/Lucid/Factory'; | ||
3 | import WorkspaceFactory from './WorkspaceFactory'; | ||
4 | import ServiceFactory from './ServiceFactory'; | ||
5 | import crypto from 'node:crypto'; | ||
6 | |||
7 | const hashedPassword = crypto | ||
8 | .createHash('sha256') | ||
9 | .update('password') | ||
10 | .digest('base64'); | ||
11 | |||
12 | export default Factory.define(User, async ({ faker }) => ({ | ||
13 | email: faker.internet.email(), | ||
14 | username: faker.internet.userName(), | ||
15 | password: hashedPassword, | ||
16 | // eslint-disable-next-line unicorn/prefer-string-replace-all | ||
17 | lastname: faker.person.lastName().replace(/'/g, ''), | ||
18 | })) | ||
19 | .relation('workspaces', () => WorkspaceFactory) | ||
20 | .relation('services', () => ServiceFactory) | ||
21 | .build(); | ||