1
0
forked from Cutlery/immich

add test for already-online assets

This commit is contained in:
Jonathan Jogenfors 2024-03-20 11:58:36 +01:00
parent 3fc6e826d5
commit cba8019243

View File

@ -306,7 +306,7 @@ describe(LibraryService.name, () => {
expect(assetMock.update).toHaveBeenCalledWith({ id: assetStub.external.id, isOffline: true }); expect(assetMock.update).toHaveBeenCalledWith({ id: assetStub.external.id, isOffline: true });
}); });
it('should skip an offline asset', async () => { it('should skip an already-offline asset', async () => {
const mockAssetJob: ILibraryOfflineJob = { const mockAssetJob: ILibraryOfflineJob = {
id: assetStub.external.id, id: assetStub.external.id,
importPaths: ['/'], importPaths: ['/'],
@ -322,6 +322,22 @@ describe(LibraryService.name, () => {
expect(assetMock.update).not.toHaveBeenCalled(); expect(assetMock.update).not.toHaveBeenCalled();
}); });
it('should do nothing if asset is still online', async () => {
const mockAssetJob: ILibraryOfflineJob = {
id: assetStub.external.id,
importPaths: ['/'],
};
assetMock.getById.mockResolvedValue(assetStub.external);
storageMock.checkFileExists.mockResolvedValue(true);
const response = await sut.handleOfflineCheck(mockAssetJob);
expect(response).toBe(JobStatus.SUCCESS);
expect(assetMock.update).not.toHaveBeenCalled();
});
it('should skip a nonexistent asset id', async () => { it('should skip a nonexistent asset id', async () => {
const mockAssetJob: ILibraryOfflineJob = { const mockAssetJob: ILibraryOfflineJob = {
id: assetStub.external.id, id: assetStub.external.id,