mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
factory for server user
This commit is contained in:
parent
535c0b0438
commit
a518ed5096
30
database/src/factories/server-user.factory.ts
Normal file
30
database/src/factories/server-user.factory.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import Faker from 'faker'
|
||||
import { define } from 'typeorm-seeding'
|
||||
import { ServerUser } from '../../entity/ServerUser'
|
||||
|
||||
interface ServerUserContext {
|
||||
username?: string
|
||||
password?: BigInt
|
||||
email?: string
|
||||
role?: string
|
||||
activated?: number
|
||||
lastLogin?: Date
|
||||
created?: Date
|
||||
modified?: Date
|
||||
}
|
||||
|
||||
define(ServerUser, (faker: typeof Faker, context?: ServerUserContext) => {
|
||||
if (!context) context = {}
|
||||
|
||||
const user = new ServerUser()
|
||||
user.username = context.username ? context.username : faker.internet.userName()
|
||||
user.password = context.password ? context.password : BigInt(0)
|
||||
user.email = context.email ? context.email : faker.internet.email()
|
||||
user.role = context.role ? context.role : 'admin'
|
||||
user.activated = context.activated ? context.activated : 0
|
||||
user.lastLogin = context.lastLogin ? context.lastLogin : faker.date.recent()
|
||||
user.created = context.created ? context.created : faker.date.recent()
|
||||
user.modified = context.modified ? context.modified : faker.date.recent()
|
||||
|
||||
return user
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user