test(settings): cover corrupt settings file falls back to defaults
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,8 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
import thb.jeanluc.adventure.io.ConsoleIO;
|
import thb.jeanluc.adventure.io.ConsoleIO;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@@ -24,4 +26,12 @@ class SettingsStoreTest {
|
|||||||
Settings loaded = new SettingsStore(dir.resolve("nope.json")).load();
|
Settings loaded = new SettingsStore(dir.resolve("nope.json")).load();
|
||||||
assertThat(loaded).isEqualTo(Settings.defaults());
|
assertThat(loaded).isEqualTo(Settings.defaults());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void corruptFileReturnsDefaults(@TempDir Path dir) throws IOException {
|
||||||
|
Path file = dir.resolve("settings.json");
|
||||||
|
Files.writeString(file, "{ not json");
|
||||||
|
Settings loaded = new SettingsStore(file).load();
|
||||||
|
assertThat(loaded).isEqualTo(Settings.defaults());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user