diff options
author | 2024-02-10 18:37:40 -0700 | |
---|---|---|
committer | 2024-02-13 06:59:44 +0530 | |
commit | e1c47572a6235fd8fd20af888ac3a11c7ae1369d (patch) | |
tree | 2dccff36a441916d7014037cef3f7ce84a790cad /database/factories | |
parent | refactor: project maintenance (diff) | |
download | ferdium-server-e1c47572a6235fd8fd20af888ac3a11c7ae1369d.tar.gz ferdium-server-e1c47572a6235fd8fd20af888ac3a11c7ae1369d.tar.zst ferdium-server-e1c47572a6235fd8fd20af888ac3a11c7ae1369d.zip |
updates
Diffstat (limited to 'database/factories')
-rw-r--r-- | database/factories/ServiceFactory.ts | 6 | ||||
-rw-r--r-- | database/factories/TokenFactory.ts | 15 | ||||
-rw-r--r-- | database/factories/UserFactory.ts | 17 | ||||
-rw-r--r-- | database/factories/WorkspaceFactory.ts | 6 |
4 files changed, 25 insertions, 19 deletions
diff --git a/database/factories/ServiceFactory.ts b/database/factories/ServiceFactory.ts index 696a049..6e91c75 100644 --- a/database/factories/ServiceFactory.ts +++ b/database/factories/ServiceFactory.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import Service from '#app/Models/Service' | 1 | import Service from '#app/Models/Service'; |
2 | import Factory from '@adonisjs/lucid/factories' | 2 | import Factory from '@adonisjs/lucid/factories'; |
3 | 3 | ||
4 | export default Factory.define(Service, ({ faker }) => ({ | 4 | export default Factory.define(Service, ({ faker }) => ({ |
5 | name: faker.company.name(), | 5 | name: faker.company.name(), |
6 | recipeId: faker.string.alphanumeric(9), | 6 | recipeId: faker.string.alphanumeric(9), |
7 | serviceId: faker.string.alphanumeric(10), | 7 | serviceId: faker.string.alphanumeric(10), |
8 | })).build() | 8 | })).build(); |
diff --git a/database/factories/TokenFactory.ts b/database/factories/TokenFactory.ts index 0774dcd..9ca03f6 100644 --- a/database/factories/TokenFactory.ts +++ b/database/factories/TokenFactory.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import Token from '#app/Models/Token' | 1 | import Token from '#app/Models/Token'; |
2 | import Factory from '@adonisjs/lucid/factories' | 2 | import Factory from '@adonisjs/lucid/factories'; |
3 | import { DateTime } from 'luxon' | 3 | import { DateTime } from 'luxon'; |
4 | 4 | ||
5 | export default Factory.define(Token, async ({ faker }) => ({ | 5 | export default Factory.define(Token, async ({ faker }) => ({ |
6 | token: faker.string.alphanumeric(32), | 6 | token: faker.string.alphanumeric(32), |
@@ -9,6 +9,9 @@ export default Factory.define(Token, async ({ faker }) => ({ | |||
9 | created_at: DateTime.now(), | 9 | created_at: DateTime.now(), |
10 | updated_at: DateTime.now(), | 10 | updated_at: DateTime.now(), |
11 | })) | 11 | })) |
12 | .state('old_token', (token) => (token.updated_at = DateTime.now().minus({ hours: 25 }))) | 12 | .state( |
13 | .state('revoked', (token) => (token.is_revoked = true)) | 13 | 'old_token', |
14 | .build() | 14 | token => (token.updated_at = DateTime.now().minus({ hours: 25 })), |
15 | ) | ||
16 | .state('revoked', token => (token.is_revoked = true)) | ||
17 | .build(); | ||
diff --git a/database/factories/UserFactory.ts b/database/factories/UserFactory.ts index caa2ea9..2e60052 100644 --- a/database/factories/UserFactory.ts +++ b/database/factories/UserFactory.ts | |||
@@ -1,10 +1,13 @@ | |||
1 | import User from '#app/Models/User' | 1 | import User from '#app/Models/User'; |
2 | import Factory from '@adonisjs/lucid/factories' | 2 | import Factory from '@adonisjs/lucid/factories'; |
3 | import WorkspaceFactory from './WorkspaceFactory.js' | 3 | import WorkspaceFactory from './WorkspaceFactory.js'; |
4 | import ServiceFactory from './ServiceFactory.js' | 4 | import ServiceFactory from './ServiceFactory.js'; |
5 | import crypto from 'node:crypto' | 5 | import crypto from 'node:crypto'; |
6 | 6 | ||
7 | const hashedPassword = crypto.createHash('sha256').update('password').digest('base64') | 7 | const hashedPassword = crypto |
8 | .createHash('sha256') | ||
9 | .update('password') | ||
10 | .digest('base64'); | ||
8 | 11 | ||
9 | export default Factory.define(User, async ({ faker }) => ({ | 12 | export default Factory.define(User, async ({ faker }) => ({ |
10 | email: faker.internet.email(), | 13 | email: faker.internet.email(), |
@@ -15,4 +18,4 @@ export default Factory.define(User, async ({ faker }) => ({ | |||
15 | })) | 18 | })) |
16 | .relation('workspaces', () => WorkspaceFactory) | 19 | .relation('workspaces', () => WorkspaceFactory) |
17 | .relation('services', () => ServiceFactory) | 20 | .relation('services', () => ServiceFactory) |
18 | .build() | 21 | .build(); |
diff --git a/database/factories/WorkspaceFactory.ts b/database/factories/WorkspaceFactory.ts index 7d29829..dcaade8 100644 --- a/database/factories/WorkspaceFactory.ts +++ b/database/factories/WorkspaceFactory.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import Workspace from '#app/Models/Workspace' | 1 | import Workspace from '#app/Models/Workspace'; |
2 | import Factory from '@adonisjs/lucid/factories' | 2 | import Factory from '@adonisjs/lucid/factories'; |
3 | 3 | ||
4 | export default Factory.define(Workspace, ({ faker }) => ({ | 4 | export default Factory.define(Workspace, ({ faker }) => ({ |
5 | name: faker.internet.userName(), | 5 | name: faker.internet.userName(), |
6 | workspaceId: faker.string.alphanumeric(10), | 6 | workspaceId: faker.string.alphanumeric(10), |
7 | })).build() | 7 | })).build(); |