diff options
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, 19 insertions, 25 deletions
diff --git a/database/factories/ServiceFactory.ts b/database/factories/ServiceFactory.ts index f675063..696a049 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 '@ioc:Adonis/Lucid/Factory'; | 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 5afc679..0774dcd 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 '@ioc:Adonis/Lucid/Factory'; | 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,9 +9,6 @@ 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( | 12 | .state('old_token', (token) => (token.updated_at = DateTime.now().minus({ hours: 25 }))) |
13 | 'old_token', | 13 | .state('revoked', (token) => (token.is_revoked = true)) |
14 | token => (token.updated_at = DateTime.now().minus({ hours: 25 })), | 14 | .build() |
15 | ) | ||
16 | .state('revoked', token => (token.is_revoked = true)) | ||
17 | .build(); | ||
diff --git a/database/factories/UserFactory.ts b/database/factories/UserFactory.ts index ee6553e..caa2ea9 100644 --- a/database/factories/UserFactory.ts +++ b/database/factories/UserFactory.ts | |||
@@ -1,13 +1,10 @@ | |||
1 | import User from 'App/Models/User'; | 1 | import User from '#app/Models/User' |
2 | import Factory from '@ioc:Adonis/Lucid/Factory'; | 2 | import Factory from '@adonisjs/lucid/factories' |
3 | import WorkspaceFactory from './WorkspaceFactory'; | 3 | import WorkspaceFactory from './WorkspaceFactory.js' |
4 | import ServiceFactory from './ServiceFactory'; | 4 | import ServiceFactory from './ServiceFactory.js' |
5 | import crypto from 'node:crypto'; | 5 | import crypto from 'node:crypto' |
6 | 6 | ||
7 | const hashedPassword = crypto | 7 | const hashedPassword = crypto.createHash('sha256').update('password').digest('base64') |
8 | .createHash('sha256') | ||
9 | .update('password') | ||
10 | .digest('base64'); | ||
11 | 8 | ||
12 | export default Factory.define(User, async ({ faker }) => ({ | 9 | export default Factory.define(User, async ({ faker }) => ({ |
13 | email: faker.internet.email(), | 10 | email: faker.internet.email(), |
@@ -18,4 +15,4 @@ export default Factory.define(User, async ({ faker }) => ({ | |||
18 | })) | 15 | })) |
19 | .relation('workspaces', () => WorkspaceFactory) | 16 | .relation('workspaces', () => WorkspaceFactory) |
20 | .relation('services', () => ServiceFactory) | 17 | .relation('services', () => ServiceFactory) |
21 | .build(); | 18 | .build() |
diff --git a/database/factories/WorkspaceFactory.ts b/database/factories/WorkspaceFactory.ts index 40cda6b..7d29829 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 '@ioc:Adonis/Lucid/Factory'; | 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() |