Skip to content

Commit 8ae6d92

Browse files
Fix paths in unit tests so that they do not fail on OS Windows
1 parent eab7363 commit 8ae6d92

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/test/java/pl/project13/maven/git/GitCommitIdMojoTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import java.io.File;
2929
import java.io.IOException;
30+
import java.nio.file.Paths;
3031
import java.util.Map;
3132
import java.util.Properties;
3233

@@ -219,19 +220,19 @@ private void assertShortDescribe(String commitDescribe, String expectedShortDesc
219220
public void testCraftPropertiesOutputFileWithRelativePath() throws IOException {
220221
GitCommitIdMojo commitIdMojo = new GitCommitIdMojo();
221222
File baseDir = new File(".");
222-
String targetDir = baseDir.getCanonicalPath() + "/";
223-
String generateGitPropertiesFilename = "target/classes/git.properties";
223+
String targetDir = baseDir.getCanonicalPath();
224+
String generateGitPropertiesFilename = Paths.get(targetDir, "target", "classes", "git.properties").toString();
224225

225226
File result = commitIdMojo.craftPropertiesOutputFile(baseDir, generateGitPropertiesFilename);
226-
assertThat(result.getCanonicalPath()).isEqualTo(targetDir + generateGitPropertiesFilename);
227+
assertThat(result.getCanonicalPath()).isEqualTo(generateGitPropertiesFilename);
227228
}
228229

229230
@Test
230231
public void testCraftPropertiesOutputFileWithFullPath() throws IOException {
231232
GitCommitIdMojo commitIdMojo = new GitCommitIdMojo();
232233
File baseDir = new File(".");
233-
String targetDir = baseDir.getCanonicalPath() + "/";
234-
String generateGitPropertiesFilename = targetDir + "target/classes/git.properties";
234+
String targetDir = baseDir.getCanonicalPath();
235+
String generateGitPropertiesFilename = Paths.get(targetDir, "target", "classes", "git.properties").toString();
235236

236237
File result = commitIdMojo.craftPropertiesOutputFile(baseDir, generateGitPropertiesFilename);
237238
assertThat(result.getCanonicalPath()).isEqualTo(generateGitPropertiesFilename);

0 commit comments

Comments
 (0)