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

Resolve test failures on windows #3960

Merged
Merged
Show file tree
Hide file tree
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 @@ -29,6 +29,7 @@ public void setUp() throws IOException {

@Test
public void whenFileDoesNotExist_thenSetOptionCreatesItAndAppendsOneLine() {
writer.close();
assertTrue(file.delete());

editor.setOption("opt1", "val1");
Expand Down Expand Up @@ -111,6 +112,7 @@ public void whenFileDoesNotContainOptionBeingCleared_thenClearOptionIsNoOp() {

@Test
public void whenFileDoesNotExist_thenClearOptionIsNoOp() {
writer.close();
assertTrue(file.delete());
editor.clearOption("opt1");
assertFalse(file.exists());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void setUp() throws IOException {

@Test
public void whenFileDoesNotExist_thenGetLinesThrows() {
writer.close();
assertTrue(file.delete());

exception.expect(ConfigException.class);
Expand Down
16 changes: 12 additions & 4 deletions common/src/test/java/bisq/common/config/ConfigTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,24 @@ public void whenUnrecognizedOptionIsSet_thenConfigExceptionIsThrown() {

@Test
public void whenOptionFileArgumentDoesNotExist_thenConfigExceptionIsThrown() {
String filepath = "/does/not/exist";
if (System.getProperty("os.name").startsWith("Windows")) {
filepath = "C:\\does\\not\\exist";
}
exceptionRule.expect(ConfigException.class);
exceptionRule.expectMessage("problem parsing option 'torrcFile': File [/does/not/exist] does not exist");
configWithOpts(opt(TORRC_FILE, "/does/not/exist"));
exceptionRule.expectMessage(format("problem parsing option 'torrcFile': File [%s] does not exist", filepath));
configWithOpts(opt(TORRC_FILE, filepath));
}

@Test
public void whenConfigFileOptionIsSetToNonExistentFile_thenConfigExceptionIsThrown() {
String filepath = "/no/such/bisq.properties";
if (System.getProperty("os.name").startsWith("Windows")) {
filepath = "C:\\no\\such\\bisq.properties";
}
exceptionRule.expect(ConfigException.class);
exceptionRule.expectMessage("The specified config file '/no/such/bisq.properties' does not exist");
configWithOpts(opt(CONFIG_FILE, "/no/such/bisq.properties"));
exceptionRule.expectMessage(format("The specified config file '%s' does not exist", filepath));
configWithOpts(opt(CONFIG_FILE, filepath));
}

@Test
Expand Down
8 changes: 6 additions & 2 deletions common/src/test/java/bisq/common/util/PreconditionsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public void whenDirIsValid_thenDirIsReturned() throws IOException {

@Test
public void whenDirDoesNotExist_thenThrow() {
String filepath = "/does/not/exist";
if (System.getProperty("os.name").startsWith("Windows")) {
filepath = "C:\\does\\not\\exist";
}
exceptionRule.expect(IllegalArgumentException.class);
exceptionRule.expectMessage(equalTo("Directory '/does/not/exist' does not exist"));
checkDir(new File("/does/not/exist"));
exceptionRule.expectMessage(equalTo(String.format("Directory '%s' does not exist", filepath)));
checkDir(new File(filepath));
}
}