feat: add reading file test

This commit is contained in:
Anthony Berg
2024-10-17 18:25:23 +02:00
parent e3a7f339f2
commit b34c2b0a86

View File

@@ -51,5 +51,26 @@ class ReadFileTest {
assertThrowsExactly(RuntimeException.class, () -> ReadFile.open(nonExistent)); assertThrowsExactly(RuntimeException.class, () -> ReadFile.open(nonExistent));
} }
@Test
@DisplayName("Reading valid file correctly")
void openValidFile() throws IOException {
String filename = "test.txt";
Path path = Files.createFile(tempDir.resolve(filename));
List<String> emails = new ArrayList<>() {{
add("test@test.com");
add("person@gmail.com");
add("hello@outlook.com");
}};
// Write the emails to the file "test.txt"
Files.write(path, emails);
// Get the output from the function
List<String> output = ReadFile.open(path);
assertEquals(emails, output);
}
} }
} }