mirror of
https://github.com/KevinMidboe/immich.git
synced 2026-01-07 01:35:49 +00:00
refactor(server): jobs and processors (#1787)
* 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
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
import { AssetEntity, AssetType } from '@app/infra/db/entities';
|
||||
import { newJobRepositoryMock } from '../../test';
|
||||
import { IAssetUploadedJob } from './interfaces';
|
||||
import { JobName } from './job.constants';
|
||||
import { IJobRepository, Job } from './job.repository';
|
||||
import { JobService } from './job.service';
|
||||
|
||||
const jobStub = {
|
||||
upload: {
|
||||
video: Object.freeze<Job<IAssetUploadedJob>>({
|
||||
data: { asset: { type: AssetType.VIDEO } as AssetEntity, fileName: 'video.mp4' },
|
||||
}),
|
||||
image: Object.freeze<Job<IAssetUploadedJob>>({
|
||||
data: { asset: { type: AssetType.IMAGE } as AssetEntity, fileName: 'image.jpg' },
|
||||
}),
|
||||
},
|
||||
};
|
||||
|
||||
describe(JobService.name, () => {
|
||||
let sut: JobService;
|
||||
let jobMock: jest.Mocked<IJobRepository>;
|
||||
|
||||
it('should work', () => {
|
||||
expect(sut).toBeDefined();
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
jobMock = newJobRepositoryMock();
|
||||
sut = new JobService(jobMock);
|
||||
});
|
||||
|
||||
describe('handleUploadedAsset', () => {
|
||||
it('should process a video', async () => {
|
||||
await expect(sut.handleUploadedAsset(jobStub.upload.video)).resolves.toBeUndefined();
|
||||
|
||||
expect(jobMock.add).toHaveBeenCalledTimes(3);
|
||||
expect(jobMock.add.mock.calls).toEqual([
|
||||
[{ name: JobName.GENERATE_JPEG_THUMBNAIL, data: { asset: { type: AssetType.VIDEO } } }],
|
||||
[{ name: JobName.VIDEO_CONVERSION, data: { asset: { type: AssetType.VIDEO } } }],
|
||||
[{ name: JobName.EXTRACT_VIDEO_METADATA, data: { asset: { type: AssetType.VIDEO }, fileName: 'video.mp4' } }],
|
||||
]);
|
||||
});
|
||||
|
||||
it('should process an image', async () => {
|
||||
await sut.handleUploadedAsset(jobStub.upload.image);
|
||||
|
||||
expect(jobMock.add).toHaveBeenCalledTimes(2);
|
||||
expect(jobMock.add.mock.calls).toEqual([
|
||||
[{ name: JobName.GENERATE_JPEG_THUMBNAIL, data: { asset: { type: AssetType.IMAGE } } }],
|
||||
[{ name: JobName.EXIF_EXTRACTION, data: { asset: { type: AssetType.IMAGE }, fileName: 'image.jpg' } }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user