mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
refactor: album service small tests (#25640)
This commit is contained in:
parent
16fe828913
commit
a356497d96
4 changed files with 832 additions and 468 deletions
|
|
@ -17,8 +17,6 @@ set
|
||||||
where
|
where
|
||||||
"userId" = $2
|
"userId" = $2
|
||||||
and "albumId" = $3
|
and "albumId" = $3
|
||||||
returning
|
|
||||||
*
|
|
||||||
|
|
||||||
-- AlbumUserRepository.delete
|
-- AlbumUserRepository.delete
|
||||||
delete from "album_user"
|
delete from "album_user"
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,13 @@ export class AlbumUserRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenerateSql({ params: [{ userId: DummyValue.UUID, albumId: DummyValue.UUID }, { role: AlbumUserRole.Viewer }] })
|
@GenerateSql({ params: [{ userId: DummyValue.UUID, albumId: DummyValue.UUID }, { role: AlbumUserRole.Viewer }] })
|
||||||
update({ userId, albumId }: AlbumPermissionId, dto: Updateable<AlbumUserTable>) {
|
async update({ userId, albumId }: AlbumPermissionId, dto: Updateable<AlbumUserTable>) {
|
||||||
return this.db
|
await this.db
|
||||||
.updateTable('album_user')
|
.updateTable('album_user')
|
||||||
.set(dto)
|
.set(dto)
|
||||||
.where('userId', '=', userId)
|
.where('userId', '=', userId)
|
||||||
.where('albumId', '=', albumId)
|
.where('albumId', '=', albumId)
|
||||||
.returningAll()
|
.execute();
|
||||||
.executeTakeFirstOrThrow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GenerateSql({ params: [{ userId: DummyValue.UUID, albumId: DummyValue.UUID }] })
|
@GenerateSql({ params: [{ userId: DummyValue.UUID, albumId: DummyValue.UUID }] })
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Activity,
|
Activity,
|
||||||
|
Album,
|
||||||
ApiKey,
|
ApiKey,
|
||||||
AssetFace,
|
AssetFace,
|
||||||
AssetFile,
|
AssetFile,
|
||||||
|
|
@ -23,6 +24,7 @@ import { AssetEditAction, AssetEditActionItem, MirrorAxis } from 'src/dtos/editi
|
||||||
import { QueueStatisticsDto } from 'src/dtos/queue.dto';
|
import { QueueStatisticsDto } from 'src/dtos/queue.dto';
|
||||||
import {
|
import {
|
||||||
AssetFileType,
|
AssetFileType,
|
||||||
|
AssetOrder,
|
||||||
AssetStatus,
|
AssetStatus,
|
||||||
AssetType,
|
AssetType,
|
||||||
AssetVisibility,
|
AssetVisibility,
|
||||||
|
|
@ -506,6 +508,24 @@ const personFactory = (person?: Partial<Person>): Person => ({
|
||||||
...person,
|
...person,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const albumFactory = (album?: Partial<Omit<Album, 'assets'>>) => ({
|
||||||
|
albumName: 'My Album',
|
||||||
|
albumThumbnailAssetId: null,
|
||||||
|
albumUsers: [],
|
||||||
|
assets: [],
|
||||||
|
createdAt: newDate(),
|
||||||
|
deletedAt: null,
|
||||||
|
description: 'Album description',
|
||||||
|
id: newUuid(),
|
||||||
|
isActivityEnabled: false,
|
||||||
|
order: AssetOrder.Desc,
|
||||||
|
ownerId: newUuid(),
|
||||||
|
sharedLinks: [],
|
||||||
|
updatedAt: newDate(),
|
||||||
|
updateId: newUuidV7(),
|
||||||
|
...album,
|
||||||
|
});
|
||||||
|
|
||||||
export const factory = {
|
export const factory = {
|
||||||
activity: activityFactory,
|
activity: activityFactory,
|
||||||
apiKey: apiKeyFactory,
|
apiKey: apiKeyFactory,
|
||||||
|
|
@ -532,6 +552,7 @@ export const factory = {
|
||||||
person: personFactory,
|
person: personFactory,
|
||||||
assetEdit: assetEditFactory,
|
assetEdit: assetEditFactory,
|
||||||
tag: tagFactory,
|
tag: tagFactory,
|
||||||
|
album: albumFactory,
|
||||||
uuid: newUuid,
|
uuid: newUuid,
|
||||||
buffer: () => Buffer.from('this is a fake buffer'),
|
buffer: () => Buffer.from('this is a fake buffer'),
|
||||||
date: newDate,
|
date: newDate,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue