예제 #1
0
func testIndividualFileYAML(file string) bool {
	// announce thyself
	fmt.Println(CLR_0, "Testing file: ", file, CLR_N)

	// set the basis and read it into memory
	basisFile := strings.Replace(file, ".lmd", ".md", 1)
	testAgainstMe := lmd.ReadAFile(basisFile)

	// make a temp file
	tempFile, tempFileErr := ioutil.TempFile(os.TempDir(), "lmd-test-")
	if tempFileErr != nil {
		log.Fatal(tempFileErr)
	}
	defer os.Remove(tempFile.Name())

	// run LegalToMarkdown on the fixture
	lmd.LegalToMarkdown(file, "", tempFile.Name())

	// read the tempfile
	iMadeThisFile := lmd.ReadAFile(tempFile.Name())

	// announce
	if testAgainstMe == iMadeThisFile {
		fmt.Println(CLR_G, "YES!\n", CLR_N)
		return true
	} else {
		fmt.Println(CLR_R, "NOOOOOOOOOOOOOOOOO.\n", CLR_N)
		fmt.Println(CLR_G, "Expected =>", CLR_N)
		fmt.Println(testAgainstMe)
		fmt.Println(CLR_R, "Result =>", CLR_N)
		fmt.Println(iMadeThisFile)
		return false
	}

}
예제 #2
0
func TestLegalToRenderingToPDF(t *testing.T) {
	fmt.Println(CLR_B, "\n\tTesting Rendering to PDF\n", CLR_N)

	testFile := filepath.Join(".", "spec", "00.load_write_no_action.md")

	// make a temp file
	tempFile, tempFileErr := ioutil.TempFile(os.TempDir(), "lmd-test-")
	if tempFileErr != nil {
		t.Error(tempFileErr)
	}
	defer os.Remove(tempFile.Name())

	// dowit
	lmd.MarkdownToPDF(testFile, "", tempFile.Name())

	// read the tempfile
	iMadeThisFile := lmd.ReadAFile(tempFile.Name())

	if iMadeThisFile == "" {
		t.Error("Did not create a pdf.")
	}
}