diff options
Diffstat (limited to 'main_test.go')
| -rw-r--r-- | main_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go index a1eda14..66d793f 100644 --- a/main_test.go +++ b/main_test.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "encoding/xml" + "html/template" "os" "path/filepath" "strings" @@ -371,6 +372,19 @@ func TestSortingFilteringSlicing(t *testing.T) { } } +func TestPathTemplateFunctions(t *testing.T) { + tmpl := template.Must(template.New("path").Funcs(templateFuncs()).Parse( + `{{$parts := splitPath "notes/sync/recipes/soup.md"}}{{dirPath (joinPath (slice $parts 2))}}|{{dirPath "soup.md"}}`, + )) + var output strings.Builder + if err := tmpl.Execute(&output, nil); err != nil { + t.Fatal(err) + } + if got := output.String(); got != "recipes|" { + t.Fatalf("path = %q, want recipes|", got) + } +} + func TestUnchangedOutputsKeepMtime(t *testing.T) { root := t.TempDir() writeTestFile(t, root, "layout.tmpl", testLayouts()) |
