Log into a temporary folder during tests

This commit is contained in:
Vankka 2022-01-29 13:40:58 +02:00
parent 61ac1ec1ec
commit ebe072858e
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0

View File

@ -32,6 +32,8 @@ import com.discordsrv.common.scheduler.Scheduler;
import com.discordsrv.common.scheduler.StandardScheduler; import com.discordsrv.common.scheduler.StandardScheduler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -41,9 +43,16 @@ public class MockDiscordSRV extends AbstractDiscordSRV<MainConfig, ConnectionCon
private final Scheduler scheduler = new StandardScheduler(this); private final Scheduler scheduler = new StandardScheduler(this);
private final Logger logger = JavaLoggerImpl.getRoot(); private final Logger logger = JavaLoggerImpl.getRoot();
private final Path path;
public MockDiscordSRV() { public MockDiscordSRV() {
load(); load();
Path path = Paths.get("/tmp/discordsrv-test");
try {
path = Files.createTempDirectory("discordsrv-test");
} catch (IOException ignored) {}
this.path = path;
} }
@Override @Override
@ -53,7 +62,7 @@ public class MockDiscordSRV extends AbstractDiscordSRV<MainConfig, ConnectionCon
@Override @Override
public Path dataDirectory() { public Path dataDirectory() {
return Paths.get(""); return path;
} }
@Override @Override