mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
* refactor: jobs and processors * refactor: storage migration processor * fix: tests * fix: code warning * chore: ignore coverage from infra * fix: sync move asset logic between job core and asset core * refactor: move error handling inside of catch * refactor(server): job core into dedicated service calls * refactor: smart info * fix: tests * chore: smart info tests * refactor: use asset repository * refactor: thumbnail processor * chore: coverage reqs
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { AssetEntity, AssetType } from '@app/infra/db/entities';
|
|
import { newJobRepositoryMock } from '../../test';
|
|
import { AssetService } from '../asset';
|
|
import { IJobRepository, JobName } from '../job';
|
|
|
|
describe(AssetService.name, () => {
|
|
let sut: AssetService;
|
|
let jobMock: jest.Mocked<IJobRepository>;
|
|
|
|
it('should work', () => {
|
|
expect(sut).toBeDefined();
|
|
});
|
|
|
|
beforeEach(async () => {
|
|
jobMock = newJobRepositoryMock();
|
|
sut = new AssetService(jobMock);
|
|
});
|
|
|
|
describe(`handle asset upload`, () => {
|
|
it('should process an uploaded video', async () => {
|
|
const data = { asset: { type: AssetType.VIDEO } as AssetEntity, fileName: 'video.mp4' };
|
|
|
|
await expect(sut.handleAssetUpload(data)).resolves.toBeUndefined();
|
|
|
|
expect(jobMock.queue).toHaveBeenCalledTimes(3);
|
|
expect(jobMock.queue.mock.calls).toEqual([
|
|
[{ name: JobName.GENERATE_JPEG_THUMBNAIL, data }],
|
|
[{ name: JobName.VIDEO_CONVERSION, data }],
|
|
[{ name: JobName.EXTRACT_VIDEO_METADATA, data }],
|
|
]);
|
|
});
|
|
|
|
it('should process an uploaded image', async () => {
|
|
const data = { asset: { type: AssetType.IMAGE } as AssetEntity, fileName: 'image.jpg' };
|
|
|
|
await sut.handleAssetUpload(data);
|
|
|
|
expect(jobMock.queue).toHaveBeenCalledTimes(2);
|
|
expect(jobMock.queue.mock.calls).toEqual([
|
|
[{ name: JobName.GENERATE_JPEG_THUMBNAIL, data }],
|
|
[{ name: JobName.EXIF_EXTRACTION, data }],
|
|
]);
|
|
});
|
|
});
|
|
});
|