Commit 5ba3285e authored by Raghav Khanna's avatar Raghav Khanna

fix file names and add file generator tests

parent 809b2d6f
Pipeline #114197 passed with stages
in 3 minutes and 56 seconds
......@@ -34,7 +34,8 @@ public class HtmlConverter {
}
try {
String pdfFilePath = mdFile.getCanonicalPath() + ".pdf";
String canocialPath = mdFile.getCanonicalPath();
String pdfFilePath = canocialPath.substring(0, canocialPath.length() - 3) + ".pdf";
new ProcessBuilder("pandoc", mdFile.getCanonicalPath(), "-o", pdfFilePath)
.start().waitFor();
......
package ic.doc;
import ic.doc.web.HtmlConverter;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class FileGenerateTest {
@Test
public void generatesMdFile() throws Exception {
assertTrue(HtmlConverter.stringToMdFile("tony", "test") != null);
}
@Test
public void generatesPdfFile() throws Exception {
assertTrue(HtmlConverter.stringToPdfFile("tony", "test") != null);
}
@Test
public void reasonableNameForMdFile() throws Exception {
assertTrue(
HtmlConverter.stringToMdFile("konstantinos", "test")
.getName()
.matches("konstantinos[0-9]+.md"));
}
@Test
public void reasonableNameForPdfFile() throws Exception {
assertTrue(HtmlConverter.stringToPdfFile("tony", "test")
.getName()
.matches("tony[0-9]+.pdf"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment