[test] Fix ConfigTest for Windows
Escape paths when writing them to a config file to ensure they work with backslashes and unusual characters. Bug: 550111 Change-Id: Iedc5c0f2c0c02ac6cadf43cdae0f0d19578aed91 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
parent
961d5e6875
commit
0588dd0a9f
|
@ -1488,7 +1488,8 @@ public void testCommitTemplateConfig()
|
||||||
String expectedTemplatePath = tempFile.getPath();
|
String expectedTemplatePath = tempFile.getPath();
|
||||||
|
|
||||||
Config config = parse(
|
Config config = parse(
|
||||||
"[commit]\n\ttemplate = " + expectedTemplatePath + "\n");
|
"[commit]\n\ttemplate = "
|
||||||
|
+ Config.escapeValue(expectedTemplatePath) + "\n");
|
||||||
|
|
||||||
String templatePath = config.get(CommitConfig.KEY)
|
String templatePath = config.get(CommitConfig.KEY)
|
||||||
.getCommitTemplatePath();
|
.getCommitTemplatePath();
|
||||||
|
@ -1537,7 +1538,8 @@ public void testCommitTemplateEncoding()
|
||||||
JGitTestUtil.write(tempFile, templateContent);
|
JGitTestUtil.write(tempFile, templateContent);
|
||||||
String expectedTemplatePath = tempFile.getPath();
|
String expectedTemplatePath = tempFile.getPath();
|
||||||
config = parse("[i18n]\n\tcommitEncoding = utf-8\n"
|
config = parse("[i18n]\n\tcommitEncoding = utf-8\n"
|
||||||
+ "[commit]\n\ttemplate = " + expectedTemplatePath + "\n");
|
+ "[commit]\n\ttemplate = "
|
||||||
|
+ Config.escapeValue(expectedTemplatePath) + "\n");
|
||||||
assertEquals(templateContent,
|
assertEquals(templateContent,
|
||||||
config.get(CommitConfig.KEY).getCommitTemplateContent(repo));
|
config.get(CommitConfig.KEY).getCommitTemplateContent(repo));
|
||||||
String commitEncoding = config.get(CommitConfig.KEY)
|
String commitEncoding = config.get(CommitConfig.KEY)
|
||||||
|
@ -1556,7 +1558,8 @@ public void testCommitTemplateWithInvalidEncoding()
|
||||||
String templateContent = "content of the template";
|
String templateContent = "content of the template";
|
||||||
JGitTestUtil.write(tempFile, templateContent);
|
JGitTestUtil.write(tempFile, templateContent);
|
||||||
config = parse("[i18n]\n\tcommitEncoding = invalidEcoding\n"
|
config = parse("[i18n]\n\tcommitEncoding = invalidEcoding\n"
|
||||||
+ "[commit]\n\ttemplate = " + tempFile.getPath() + "\n");
|
+ "[commit]\n\ttemplate = "
|
||||||
|
+ Config.escapeValue(tempFile.getPath()) + "\n");
|
||||||
config.get(CommitConfig.KEY).getCommitTemplateContent(repo);
|
config.get(CommitConfig.KEY).getCommitTemplateContent(repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1570,7 +1573,7 @@ public void testCommitTemplateWithInvalidPath()
|
||||||
String templateContent = "content of the template";
|
String templateContent = "content of the template";
|
||||||
JGitTestUtil.write(tempFile, templateContent);
|
JGitTestUtil.write(tempFile, templateContent);
|
||||||
// commit message encoding
|
// commit message encoding
|
||||||
String expectedTemplatePath = "/nonExistingTemplate";
|
String expectedTemplatePath = "~/nonExistingTemplate";
|
||||||
config = parse("[commit]\n\ttemplate = " + expectedTemplatePath + "\n");
|
config = parse("[commit]\n\ttemplate = " + expectedTemplatePath + "\n");
|
||||||
String templatePath = config.get(CommitConfig.KEY)
|
String templatePath = config.get(CommitConfig.KEY)
|
||||||
.getCommitTemplatePath();
|
.getCommitTemplatePath();
|
||||||
|
|
Loading…
Reference in New Issue