summaryrefslogtreecommitdiff
path: root/main_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go
index 66d793f..f6c943e 100644
--- a/main_test.go
+++ b/main_test.go
@@ -354,6 +354,28 @@ func TestGitignoreTracksOnlyCurrentGeneratedOutputs(t *testing.T) {
}
}
+func TestGitignoreOmitsOutputsBelowSymlinks(t *testing.T) {
+ root := t.TempDir()
+ vault := t.TempDir()
+ writeTestFile(t, root, ".gitignore", gitignoreStart+"\n/notes/note.html\n"+gitignoreEnd+"\n")
+ writeTestFile(t, root, "layouts.tmpl", testLayouts())
+ writeTestFile(t, root, "local.md", "# Local\n")
+ writeTestFile(t, vault, "note.md", "# Note\n")
+ if err := os.Symlink(vault, filepath.Join(root, "notes")); err != nil {
+ t.Skipf("symlinks unavailable: %v", err)
+ }
+ if err := buildWithFallback(root, "https://example.com", "page", true); err != nil {
+ t.Fatal(err)
+ }
+ want := gitignoreStart + "\n/local.html\n" + gitignoreEnd + "\n"
+ if raw, _ := os.ReadFile(filepath.Join(root, ".gitignore")); string(raw) != want {
+ t.Fatalf(".gitignore = %q, want %q", raw, want)
+ }
+ if raw, _ := os.ReadFile(filepath.Join(root, manifestName)); !strings.Contains(string(raw), `"notes/note.html"`) {
+ t.Fatalf("manifest does not own symlinked output: %s", raw)
+ }
+}
+
func TestSortingFilteringSlicing(t *testing.T) {
a := &Page{Title: "A", Meta: map[string]any{"post_date": "2024-01-01", "kind": "x"}, ModTime: time.Unix(1, 0)}
b := &Page{Title: "B", Meta: map[string]any{"post_date": "2025-01-01", "kind": "y"}, ModTime: time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)}