mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
Merge branch 'main' into feat/mobile-ocr
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { AssetEditAction } from 'src/dtos/editing.dto';
|
||||
import { AssetEditRepository } from 'src/repositories/asset-edit.repository';
|
||||
import { LoggingRepository } from 'src/repositories/logging.repository';
|
||||
import { PartnerRepository } from 'src/repositories/partner.repository';
|
||||
import { UserRepository } from 'src/repositories/user.repository';
|
||||
@@ -45,6 +47,27 @@ describe('audit', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('asset_edit_audit', () => {
|
||||
it('should not cascade asset deletes to asset_edit_audit', async () => {
|
||||
const assetEditRepo = ctx.get(AssetEditRepository);
|
||||
const { user } = await ctx.newUser();
|
||||
const { asset } = await ctx.newAsset({ ownerId: user.id });
|
||||
|
||||
await assetEditRepo.replaceAll(asset.id, [
|
||||
{
|
||||
action: AssetEditAction.Crop,
|
||||
parameters: { x: 10, y: 20, width: 100, height: 200 },
|
||||
},
|
||||
]);
|
||||
|
||||
await ctx.database.deleteFrom('asset').where('id', '=', asset.id).execute();
|
||||
|
||||
await expect(
|
||||
ctx.database.selectFrom('asset_edit_audit').select(['id']).where('assetId', '=', asset.id).execute(),
|
||||
).resolves.toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('assets_audit', () => {
|
||||
it('should not cascade user deletes to assets_audit', async () => {
|
||||
const userRepo = ctx.get(UserRepository);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { schemaFromCode } from '@immich/sql-tools';
|
||||
import { Kysely } from 'kysely';
|
||||
import { DateTime } from 'luxon';
|
||||
import { AssetMetadataKey, UserMetadataKey } from 'src/enum';
|
||||
import { DatabaseRepository } from 'src/repositories/database.repository';
|
||||
import { LoggingRepository } from 'src/repositories/logging.repository';
|
||||
import { SyncRepository } from 'src/repositories/sync.repository';
|
||||
import { BaseSync, SyncRepository } from 'src/repositories/sync.repository';
|
||||
import { DB } from 'src/schema';
|
||||
import { SyncService } from 'src/services/sync.service';
|
||||
import { newMediumService } from 'test/medium.factory';
|
||||
@@ -222,5 +223,21 @@ describe(SyncService.name, () => {
|
||||
expect(after).toHaveLength(1);
|
||||
expect(after[0].id).toBe(keep.id);
|
||||
});
|
||||
|
||||
it('should cleanup every table', async () => {
|
||||
const { sut } = setup();
|
||||
|
||||
const auditTables = schemaFromCode()
|
||||
.tables.filter((table) => table.name.endsWith('_audit'))
|
||||
.map(({ name }) => name);
|
||||
|
||||
const auditCleanupSpy = vi.spyOn(BaseSync.prototype as any, 'auditCleanup');
|
||||
await expect(sut.onAuditTableCleanup()).resolves.toBeUndefined();
|
||||
|
||||
expect(auditCleanupSpy).toHaveBeenCalledTimes(auditTables.length);
|
||||
for (const table of auditTables) {
|
||||
expect(auditCleanupSpy, `Audit table ${table} was not cleaned up`).toHaveBeenCalledWith(table, 31);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user