refactor: migrate library repository to kysely (#15271)
This commit is contained in:
@@ -87,7 +87,7 @@ describe(LibraryService.name, () => {
|
||||
Promise.resolve(
|
||||
[libraryStub.externalLibraryWithImportPaths1, libraryStub.externalLibraryWithImportPaths2].find(
|
||||
(library) => library.id === id,
|
||||
) || null,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -190,8 +190,6 @@ describe(LibraryService.name, () => {
|
||||
});
|
||||
|
||||
it("should fail when library can't be found", async () => {
|
||||
libraryMock.get.mockResolvedValue(null);
|
||||
|
||||
await expect(sut.handleQueueSyncFiles({ id: libraryStub.externalLibrary1.id })).resolves.toBe(JobStatus.SKIPPED);
|
||||
});
|
||||
|
||||
@@ -242,8 +240,6 @@ describe(LibraryService.name, () => {
|
||||
});
|
||||
|
||||
it("should fail when library can't be found", async () => {
|
||||
libraryMock.get.mockResolvedValue(null);
|
||||
|
||||
await expect(sut.handleQueueSyncAssets({ id: libraryStub.externalLibrary1.id })).resolves.toBe(JobStatus.SKIPPED);
|
||||
});
|
||||
});
|
||||
@@ -630,7 +626,6 @@ describe(LibraryService.name, () => {
|
||||
});
|
||||
|
||||
it('should throw an error when a library is not found', async () => {
|
||||
libraryMock.get.mockResolvedValue(null);
|
||||
await expect(sut.get(libraryStub.externalLibrary1.id)).rejects.toBeInstanceOf(BadRequestException);
|
||||
expect(libraryMock.get).toHaveBeenCalledWith(libraryStub.externalLibrary1.id);
|
||||
});
|
||||
@@ -825,7 +820,10 @@ describe(LibraryService.name, () => {
|
||||
await expect(sut.update('library-id', { importPaths: [`${cwd}/foo/bar`] })).resolves.toEqual(
|
||||
mapLibrary(libraryStub.externalLibrary1),
|
||||
);
|
||||
expect(libraryMock.update).toHaveBeenCalledWith(expect.objectContaining({ id: 'library-id' }));
|
||||
expect(libraryMock.update).toHaveBeenCalledWith(
|
||||
'library-id',
|
||||
expect.objectContaining({ importPaths: [`${cwd}/foo/bar`] }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1015,7 +1013,7 @@ describe(LibraryService.name, () => {
|
||||
Promise.resolve(
|
||||
[libraryStub.externalLibraryWithImportPaths1, libraryStub.externalLibraryWithImportPaths2].find(
|
||||
(library) => library.id === id,
|
||||
) || null,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ export class LibraryService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
const library = await this.libraryRepository.update({ id, ...dto });
|
||||
const library = await this.libraryRepository.update(id, dto);
|
||||
return mapLibrary(library);
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ export class LibraryService extends BaseService {
|
||||
this.logger.debug(`No non-excluded assets found in any import path for library ${library.id}`);
|
||||
}
|
||||
|
||||
await this.libraryRepository.update({ id: job.id, refreshedAt: new Date() });
|
||||
await this.libraryRepository.update(job.id, { refreshedAt: new Date() });
|
||||
|
||||
return JobStatus.SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user