1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-25 13:12:46 +01:00
immich/server/libs/domain/src/storage/storage.service.spec.ts
Jason Rasmussen 6c7679714b
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
2023-02-25 08:12:03 -06:00

39 lines
1.2 KiB
TypeScript

import { newStorageRepositoryMock } from '../../test';
import { IStorageRepository } from '../storage';
import { StorageService } from './storage.service';
describe(StorageService.name, () => {
let sut: StorageService;
let storageMock: jest.Mocked<IStorageRepository>;
beforeEach(async () => {
storageMock = newStorageRepositoryMock();
sut = new StorageService(storageMock);
});
it('should work', () => {
expect(sut).toBeDefined();
});
describe('handleDeleteFiles', () => {
it('should handle null values', async () => {
await sut.handleDeleteFiles({ files: [undefined, null] });
expect(storageMock.unlink).not.toHaveBeenCalled();
});
it('should handle an error removing a file', async () => {
storageMock.unlink.mockRejectedValue(new Error('something-went-wrong'));
await sut.handleDeleteFiles({ files: ['path/to/something'] });
expect(storageMock.unlink).toHaveBeenCalledWith('path/to/something');
});
it('should remove the file', async () => {
await sut.handleDeleteFiles({ files: ['path/to/something'] });
expect(storageMock.unlink).toHaveBeenCalledWith('path/to/something');
});
});
});