mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-25 01:41:40 +00:00
Point config test to testconfigdir instead of default config dir (#49)
This commit is contained in:
@@ -36,7 +36,7 @@ public class ConfigManager {
|
||||
private static ConfigManager INSTANCE;
|
||||
|
||||
private PhotonConfiguration config;
|
||||
private final File rootFolder;
|
||||
final File rootFolder;
|
||||
private final File hardwareConfigFile;
|
||||
private final File networkConfigFile;
|
||||
private final File camerasFolder;
|
||||
@@ -52,11 +52,11 @@ public class ConfigManager {
|
||||
return config;
|
||||
}
|
||||
|
||||
protected static Path getRootFolder() {
|
||||
private static Path getRootFolder() {
|
||||
return Path.of("photonvision");
|
||||
}
|
||||
|
||||
private ConfigManager(Path rootFolder) {
|
||||
ConfigManager(Path rootFolder) {
|
||||
this.rootFolder = new File(rootFolder.toUri());
|
||||
this.hardwareConfigFile =
|
||||
new File(Path.of(rootFolder.toString(), "hardwareConfig.json").toUri());
|
||||
@@ -246,7 +246,7 @@ public class ConfigManager {
|
||||
.map(
|
||||
p -> {
|
||||
var relativizedFilePath =
|
||||
getRootFolder().toAbsolutePath().relativize(p).toString();
|
||||
rootFolder.toPath().toAbsolutePath().relativize(p).toString();
|
||||
try {
|
||||
return JacksonUtils.deserialize(p, CVPipelineSettings.class);
|
||||
} catch (JsonProcessingException e) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.photonvision.common.logging.LogGroup;
|
||||
import org.photonvision.common.logging.LogLevel;
|
||||
@@ -44,7 +45,7 @@ public class ConfigTest {
|
||||
|
||||
static {
|
||||
TestUtils.loadLibraries();
|
||||
configMgr = ConfigManager.getInstance();
|
||||
configMgr = new ConfigManager(Path.of("testconfigdir"));
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
@@ -74,16 +75,16 @@ public class ConfigTest {
|
||||
|
||||
var camConfDir =
|
||||
new File(
|
||||
Path.of(ConfigManager.getRootFolder().toString(), "cameras", "TestCamera")
|
||||
Path.of(configMgr.rootFolder.toString(), "cameras", "TestCamera")
|
||||
.toAbsolutePath()
|
||||
.toString());
|
||||
Assertions.assertTrue(camConfDir.exists(), "TestCamera config folder not found!");
|
||||
|
||||
Assertions.assertTrue(
|
||||
Files.exists(Path.of(ConfigManager.getRootFolder().toString(), "hardwareConfig.json")),
|
||||
Files.exists(Path.of(configMgr.rootFolder.toString(), "hardwareConfig.json")),
|
||||
"hardwareConfig.json file not found!");
|
||||
Assertions.assertTrue(
|
||||
Files.exists(Path.of(ConfigManager.getRootFolder().toString(), "networkSettings.json")),
|
||||
Files.exists(Path.of(configMgr.rootFolder.toString(), "networkSettings.json")),
|
||||
"networkSettings.json file not found!");
|
||||
}
|
||||
|
||||
@@ -108,13 +109,14 @@ public class ConfigTest {
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void cleanup() {
|
||||
public static void cleanup() throws IOException {
|
||||
try {
|
||||
Files.deleteIfExists(Paths.get("settings.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
new File(ConfigManager.getRootFolder().toAbsolutePath().toString()).delete();
|
||||
FileUtils.cleanDirectory(configMgr.rootFolder);
|
||||
configMgr.rootFolder.delete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user