Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test to use a file from another temp directory #5158

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,24 @@ public void testParseWordListError() throws IOException {
assertEquals("Line [1]: Error while parsing rule = abcd", ex.getMessage());
}

public void testParseWordListOutsideConfigDirError() {
public void testParseWordListOutsideConfigDirError() throws IOException {
Path home = createTempDir();
Path dict = home.resolve("/etc/os-release");
Path temp = createTempDir();
Path dict = temp.resolve("foo.dict");
try (BufferedWriter writer = Files.newBufferedWriter(dict, StandardCharsets.UTF_8)) {
writer.write("abcd");
writer.write('\n');
}
Settings nodeSettings = Settings.builder().put("foo.bar_path", dict).put(Environment.PATH_HOME_SETTING.getKey(), home).build();
Environment env = TestEnvironment.newEnvironment(nodeSettings);
RuntimeException ex = expectThrows(
RuntimeException.class,
() -> Analysis.parseWordList(env, nodeSettings, "foo.bar", s -> { throw new RuntimeException("Error while parsing"); })
() -> Analysis.parseWordList(
env,
nodeSettings,
"foo.bar",
s -> { throw new RuntimeException("Error while parsing rule = " + s); }
)
);
assertEquals("Line [1]: Invalid rule", ex.getMessage());
}
Expand Down