mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
Fix SongodaYamlConfigTest leaving created backup files in tmp dir
This commit is contained in:
parent
fce5c5c6a1
commit
c9a48387de
@ -10,22 +10,32 @@ import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Comparator;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
||||
class SongodaYamlConfigTest {
|
||||
Path tmpDir;
|
||||
Path cfg;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws IOException {
|
||||
this.cfg = createTmpFile();
|
||||
this.tmpDir = Files.createTempDirectory("SongodaYamlConfigTest");
|
||||
|
||||
this.cfg = Files.createTempFile(this.tmpDir, "config", ".yml");
|
||||
this.tmpDir.toFile().deleteOnExit();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void tearDown() throws IOException {
|
||||
Files.deleteIfExists(this.cfg);
|
||||
try (Stream<Path> stream = Files.walk(this.tmpDir)) {
|
||||
stream
|
||||
.sorted(Comparator.reverseOrder())
|
||||
.map(Path::toFile).forEach(File::delete);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -115,7 +125,7 @@ class SongodaYamlConfigTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultValueAppliedAfterLoadNullValue() throws IOException {
|
||||
void testDefaultValueAppliedAfterLoadNullValue() {
|
||||
SongodaYamlConfig cfg = new SongodaYamlConfig(this.cfg.toFile());
|
||||
ConfigEntry entry = new ConfigEntry(cfg, "key", "value");
|
||||
|
||||
@ -123,12 +133,4 @@ class SongodaYamlConfigTest {
|
||||
|
||||
assertEquals("value", entry.get());
|
||||
}
|
||||
|
||||
private Path createTmpFile() throws IOException {
|
||||
Path path = Files.createTempFile("SongodaYamlConfigTest", "yml");
|
||||
File file = path.toFile();
|
||||
file.deleteOnExit();
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user