Rework to avoid using preferences object to retrieve options

This commit is contained in:
Guillaume Tâche
2024-09-22 21:59:10 +02:00
parent 7f99c48e2c
commit c59619da2d
115 changed files with 2294 additions and 765 deletions

View File

@@ -70,8 +70,8 @@ public class CondaSetupManager extends AbstractSetupManager {
logger.info("Conda downloaded");
}
switch (configuration.os()) {
case OS.WINDOWS -> installWindows();
case OS.MAC, OS.LINUX -> installLinux();
case WINDOWS -> installWindows();
case MAC, LINUX -> installLinux();
default -> throw new SetupException("Unsupported OS: " + configuration.os());
}
}
@@ -106,9 +106,9 @@ public class CondaSetupManager extends AbstractSetupManager {
private void downloadConda() throws SetupException {
switch (configuration.os()) {
case OS.WINDOWS -> downloadCondaWindows();
case OS.MAC -> downloadCondaMac();
case OS.LINUX -> downloadCondaLinux();
case WINDOWS -> downloadCondaWindows();
case MAC -> downloadCondaMac();
case LINUX -> downloadCondaLinux();
default -> throw new SetupException("Unsupported OS: " + configuration.os());
}
logger.info("Downloaded conda to {}", configuration.condaInstallerPath());

View File

@@ -43,7 +43,7 @@ class TestCondaSetupManager {
private final Path systemPath;
TestCondaSetupManager(@Mock final CondaSetupConfiguration configuration, @Mock final ProcessRunner processRunner,
@Mock final HttpClient httpClient, @Mock final ProcessResult systemProcessResult, @Mock final HttpResponse<Path> response) throws IOException, InterruptedException {
@Mock final HttpClient httpClient, @Mock final ProcessResult systemProcessResult, @Mock final HttpResponse<Path> response) {
this.configuration = requireNonNull(configuration);
this.processRunner = requireNonNull(processRunner);
this.httpClient = requireNonNull(httpClient);
@@ -167,7 +167,7 @@ class TestCondaSetupManager {
}
@Test
void testInstallDownloadLinuxUnsupported(@TempDir final Path tempDir) throws IOException {
void testInstallDownloadLinuxUnsupported(@TempDir final Path tempDir) {
final var installerPath = tempDir.resolve("conda");
when(configuration.condaInstallerPath()).thenReturn(installerPath);
when(configuration.condaBundledPath()).thenReturn(tempDir);
@@ -221,7 +221,7 @@ class TestCondaSetupManager {
}
@Test
void testInstallDownloadMacUnsupported(@TempDir final Path tempDir) throws IOException {
void testInstallDownloadMacUnsupported(@TempDir final Path tempDir) {
final var installerPath = tempDir.resolve("conda");
when(configuration.condaInstallerPath()).thenReturn(installerPath);
when(configuration.condaBundledPath()).thenReturn(tempDir);
@@ -235,7 +235,7 @@ class TestCondaSetupManager {
}
@Test
void testInstallDownloadUnsupported(@TempDir final Path tempDir) throws IOException {
void testInstallDownloadUnsupported(@TempDir final Path tempDir) {
final var installerPath = tempDir.resolve("conda");
when(configuration.condaInstallerPath()).thenReturn(installerPath);
when(configuration.condaBundledPath()).thenReturn(tempDir);
@@ -258,7 +258,7 @@ class TestCondaSetupManager {
when(systemProcessResult.exitCode()).thenReturn(1);
when(configuration.condaRootPath()).thenReturn(tempDir);
final var args = List.of(installerPath.toString(), "/InstallationType=JustMe", "/RegisterPython=0", "/S", "/D=" + tempDir.toString());
final var args = List.of(installerPath.toString(), "/InstallationType=JustMe", "/RegisterPython=0", "/S", "/D=" + tempDir);
final var result = mock(ProcessResult.class);
when(result.exitCode()).thenReturn(0);
when(processRunner.run(args, Duration.ofMinutes(15))).thenReturn(result);