fix(api): check legacy tools path for binaries (#146)
the kepubify / ffprobe binaries may be on disk but they're in the "data" directory under `tools` rather than under the current directory
This commit is contained in:
@@ -14,6 +14,7 @@ import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -305,6 +306,40 @@ class FileServiceTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("findSystemFile")
|
||||
class FindSystemFileTest {
|
||||
@Test
|
||||
void searchesLocalBinFolderFirst() {
|
||||
Path expected = Path.of("bin/example").toAbsolutePath().normalize();
|
||||
|
||||
try (
|
||||
MockedStatic<Files> filesMock = mockStatic(Files.class);
|
||||
) {
|
||||
filesMock.when(() -> Files.isRegularFile(any())).thenReturn(true);
|
||||
|
||||
Path actual = fileService.findSystemFile("example");
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void searchesAppDataToolsFolder() {
|
||||
Path expected = tempDir.resolve("tools", "example");
|
||||
|
||||
try (
|
||||
MockedStatic<Files> filesMock = mockStatic(Files.class);
|
||||
) {
|
||||
filesMock.when(() -> Files.isRegularFile(any())).thenReturn(false, true);
|
||||
|
||||
Path actual = fileService.findSystemFile("example");
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("Other path methods")
|
||||
class OtherPathTests {
|
||||
|
||||
Reference in New Issue
Block a user