package html2pdf import ( "fmt" "os" "path/filepath" "strings" "testing" "gitea.tecamino.com/paadi/html2pdf/converter" "gitea.tecamino.com/paadi/html2pdf/models" ) func TestConvert(t *testing.T) { t.Log("start test convert one file") err := Convert("./assets", "dst/test.html", "out.pdf") if err != nil { t.Fatal(err) } } func TestConvertFiles(t *testing.T) { t.Log("start test convert files") rootPath := "dst" files, err := os.ReadDir(rootPath) if err != nil { t.Fatal(err) } var input []models.File for _, f := range files { ext := filepath.Ext(f.Name()) if ext != ".html" { continue } input = append(input, models.File{ Input: filepath.Join(rootPath, f.Name()), Output: strings.Replace(f.Name(), ext, ".pdf", 1), }) } c, err := converter.NewConverter("assets/chrome-headless-shell/win64") if err != nil { t.Fatal(err) } defer c.Close() c.SetProgressCallback(func(progress int) { fmt.Println(progress) }) if err := c.Convert(input...); err != nil { t.Fatal(err) } t.Log("test successfull") }