From b34c2b0a865929bc9ce10f097f252ed518e9e382 Mon Sep 17 00:00:00 2001 From: Anthony Berg Date: Thu, 17 Oct 2024 18:25:23 +0200 Subject: [PATCH] feat: add reading file test --- app/src/test/java/ReadFileTest.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/src/test/java/ReadFileTest.java b/app/src/test/java/ReadFileTest.java index 4dbb517..662092f 100644 --- a/app/src/test/java/ReadFileTest.java +++ b/app/src/test/java/ReadFileTest.java @@ -51,5 +51,26 @@ class ReadFileTest { 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 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 output = ReadFile.open(path); + + assertEquals(emails, output); + } } } \ No newline at end of file