chore: prepare docfill project for gitea
This commit is contained in:
@@ -153,6 +153,30 @@ func TestRenderDOCXReplacesPlaceholderSplitAcrossTextNodes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRenderDOCXReplacesMultipleSplitPlaceholdersInSameParagraph(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
templatePath := filepath.Join(dir, "template.docx")
|
||||
outputPath := filepath.Join(dir, "out.docx")
|
||||
writeMinimalDocx(t, templatePath, `<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:p><w:r><w:t>员工:{{na</w:t></w:r><w:r><w:t>me}}</w:t></w:r><w:r><w:t>,完成:{{do</w:t></w:r><w:r><w:t>ne}}</w:t></w:r><w:r><w:t>,备注:{{note}}</w:t></w:r></w:p></w:body></w:document>`)
|
||||
|
||||
err := renderTemplate(templatePath, outputPath, map[string]string{
|
||||
"name": "Alice",
|
||||
"done": "接口数据整理",
|
||||
"note": "保持同段落",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("renderTemplate returned error: %v", err)
|
||||
}
|
||||
|
||||
got := readZipEntry(t, outputPath, "word/document.xml")
|
||||
if !strings.Contains(got, "员工:Alice,完成:接口数据整理,备注:保持同段落") {
|
||||
t.Fatalf("document.xml = %q, want rendered split placeholders", got)
|
||||
}
|
||||
if strings.Contains(got, "{{") || strings.Contains(got, "}}") {
|
||||
t.Fatalf("document.xml still has placeholder markers: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunGeneratesOneOutputPerInputRow(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
dataPath := filepath.Join(dir, "data.xlsx")
|
||||
|
||||
Reference in New Issue
Block a user