refactor: migrate library repository to kysely (#15271)

This commit is contained in:
Daniel Dietzler
2025-01-15 22:01:28 +01:00
committed by GitHub
parent 81568dbda3
commit a2207f2eef
5 changed files with 225 additions and 205 deletions

View File

@@ -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,
),
),
);