Skip to content

Commit

Permalink
reflect the review about 'file to small' test
Browse files Browse the repository at this point in the history
  • Loading branch information
llama90 committed Jun 17, 2024
1 parent 46a4af1 commit 34db1d7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.FileOutputStream;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.ipc.InvalidArrowFileException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -76,7 +78,7 @@ public void testDiffFolder() throws Exception {
}

@Test
public void testNotPreparedInput() throws Exception {
public void testNotFoundInput() {
File testInFile = new File(testFolder, "testIn.arrow");
File testOutFile = new File(testFolder, "testOut.arrow");

Expand All @@ -90,4 +92,23 @@ public void testNotPreparedInput() throws Exception {

assertTrue(exception.getMessage().contains("input file not found"));
}

@Test
public void testSmallSizeInput() throws Exception {
File testInFile = new File(testFolder, "testIn.arrow");
File testOutFile = new File(testFolder, "testOut.arrow");

// create an empty file
new FileOutputStream(testInFile).close();

String[] args = {"-i", testInFile.getAbsolutePath(), "-o", testOutFile.getAbsolutePath()};
Exception exception =
assertThrows(
InvalidArrowFileException.class,
() -> {
new FileRoundtrip(System.err).run(args);
});

assertEquals("file too small: 0", exception.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,12 @@ public void testInvalid() throws Exception {
Command.VALIDATE.name()
};
// this should fail
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> {
integration.run(args3);
});
IllegalArgumentException e =
assertThrows(
IllegalArgumentException.class,
() -> {
integration.run(args3);
});

assertTrue(e.getMessage().contains("Different values in column"), e.getMessage());
assertTrue(e.getMessage().contains("999"), e.getMessage());
Expand Down

0 comments on commit 34db1d7

Please sign in to comment.