Enhance error handling

This commit is contained in:
Rene Pfeuffer
2019-12-05 10:06:17 +01:00
parent 791437a905
commit b2bbd1d9b5
2 changed files with 63 additions and 18 deletions

View File

@@ -73,6 +73,19 @@ class CopyOnWriteTest {
Assertions.assertThat(unchangedOriginalFile).hasContent("this should be kept");
}
@Test
void shouldNotWrapRuntimeExceptions(@TempDirectory.TempDir Path tempDir) throws IOException {
Path someFile = tempDir.resolve("something.txt");
assertThrows(
NullPointerException.class,
() -> withTemporaryFile(
file -> {
throw new NullPointerException("test");
},
someFile));
}
@Test
void shouldKeepBackupIfTemporaryFileIsMissing(@TempDirectory.TempDir Path tempDir) throws IOException {
Path backedUpFile = tempDir.resolve("notToBeDeleted.txt");