mirror of
https://github.com/bisq-network/bisq.git
synced 2025-03-03 18:56:59 +01:00
Resolve test failures on windows (#3960)
* Close stream writer prior to deleting temp file On Windows, instantiating the stream writer appears to lock the file, preventing the file from being deleted. This was causing the assertion that the file is deleted to fail. * Use proper file path on Windows On Windows, the exception message contained backwards slashes causing the test to fail. * Resolve codacy issues
This commit is contained in:
parent
923487ed22
commit
d166e08d43
4 changed files with 21 additions and 6 deletions
|
@ -29,6 +29,7 @@ public class ConfigFileEditorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenFileDoesNotExist_thenSetOptionCreatesItAndAppendsOneLine() {
|
public void whenFileDoesNotExist_thenSetOptionCreatesItAndAppendsOneLine() {
|
||||||
|
writer.close();
|
||||||
assertTrue(file.delete());
|
assertTrue(file.delete());
|
||||||
|
|
||||||
editor.setOption("opt1", "val1");
|
editor.setOption("opt1", "val1");
|
||||||
|
@ -111,6 +112,7 @@ public class ConfigFileEditorTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenFileDoesNotExist_thenClearOptionIsNoOp() {
|
public void whenFileDoesNotExist_thenClearOptionIsNoOp() {
|
||||||
|
writer.close();
|
||||||
assertTrue(file.delete());
|
assertTrue(file.delete());
|
||||||
editor.clearOption("opt1");
|
editor.clearOption("opt1");
|
||||||
assertFalse(file.exists());
|
assertFalse(file.exists());
|
||||||
|
|
|
@ -32,6 +32,7 @@ public class ConfigFileReaderTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenFileDoesNotExist_thenGetLinesThrows() {
|
public void whenFileDoesNotExist_thenGetLinesThrows() {
|
||||||
|
writer.close();
|
||||||
assertTrue(file.delete());
|
assertTrue(file.delete());
|
||||||
|
|
||||||
exception.expect(ConfigException.class);
|
exception.expect(ConfigException.class);
|
||||||
|
|
|
@ -115,16 +115,24 @@ public class ConfigTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenOptionFileArgumentDoesNotExist_thenConfigExceptionIsThrown() {
|
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.expect(ConfigException.class);
|
||||||
exceptionRule.expectMessage("problem parsing option 'torrcFile': File [/does/not/exist] does not exist");
|
exceptionRule.expectMessage(format("problem parsing option 'torrcFile': File [%s] does not exist", filepath));
|
||||||
configWithOpts(opt(TORRC_FILE, "/does/not/exist"));
|
configWithOpts(opt(TORRC_FILE, filepath));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenConfigFileOptionIsSetToNonExistentFile_thenConfigExceptionIsThrown() {
|
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.expect(ConfigException.class);
|
||||||
exceptionRule.expectMessage("The specified config file '/no/such/bisq.properties' does not exist");
|
exceptionRule.expectMessage(format("The specified config file '%s' does not exist", filepath));
|
||||||
configWithOpts(opt(CONFIG_FILE, "/no/such/bisq.properties"));
|
configWithOpts(opt(CONFIG_FILE, filepath));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -27,8 +27,12 @@ public class PreconditionsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenDirDoesNotExist_thenThrow() {
|
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.expect(IllegalArgumentException.class);
|
||||||
exceptionRule.expectMessage(equalTo("Directory '/does/not/exist' does not exist"));
|
exceptionRule.expectMessage(equalTo(String.format("Directory '%s' does not exist", filepath)));
|
||||||
checkDir(new File("/does/not/exist"));
|
checkDir(new File(filepath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue