mirror of
https://github.com/immich-app/immich.git
synced 2026-02-12 11:58:15 +03:00
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { Selectable } from 'kysely';
|
|
import { UserStatus } from 'src/enum';
|
|
import { UserMetadataTable } from 'src/schema/tables/user-metadata.table';
|
|
import { UserTable } from 'src/schema/tables/user.table';
|
|
import { UserLike } from 'test/factories/types';
|
|
import { newDate, newUuid, newUuidV7 } from 'test/small.factory';
|
|
|
|
export class UserFactory {
|
|
private constructor(private value: Selectable<UserTable>) {}
|
|
|
|
static create(dto: UserLike = {}) {
|
|
return UserFactory.from(dto).build();
|
|
}
|
|
|
|
static from(dto: UserLike = {}) {
|
|
return new UserFactory({
|
|
id: newUuid(),
|
|
email: 'test@immich.cloud',
|
|
password: '',
|
|
pinCode: null,
|
|
createdAt: newDate(),
|
|
profileImagePath: '',
|
|
isAdmin: false,
|
|
shouldChangePassword: false,
|
|
avatarColor: null,
|
|
deletedAt: null,
|
|
oauthId: '',
|
|
updatedAt: newDate(),
|
|
storageLabel: null,
|
|
name: 'Test User',
|
|
quotaSizeInBytes: null,
|
|
quotaUsageInBytes: 0,
|
|
status: UserStatus.Active,
|
|
profileChangedAt: newDate(),
|
|
updateId: newUuidV7(),
|
|
...dto,
|
|
});
|
|
}
|
|
|
|
build() {
|
|
return {
|
|
...this.value,
|
|
metadata: [] as UserMetadataTable[],
|
|
};
|
|
}
|
|
}
|