diff options
Diffstat (limited to 'internal/engine/facts_test.go')
| -rw-r--r-- | internal/engine/facts_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/engine/facts_test.go b/internal/engine/facts_test.go index c511804..7d844a0 100644 --- a/internal/engine/facts_test.go +++ b/internal/engine/facts_test.go @@ -75,3 +75,20 @@ func TestContentKeepsRawWithTwoVariants(t *testing.T) { t.Fatalf("second variant: got %q, %v, want the unfolded original (raw text must still be available)", got, err) } } + +// TestDisplayOriginalAbbreviatesHome: a duplicate's original is shown +// root-relative inside the root, and home-abbreviated outside it, the way +// every other user-visible path is; a path outside $HOME stays absolute. +func TestDisplayOriginalAbbreviatesHome(t *testing.T) { + h := sandbox(t) + root := filepath.Join(h, "downloads") + for _, tt := range []struct{ orig, want string }{ + {filepath.Join(root, "x", "a.pdf"), "x/a.pdf"}, + {filepath.Join(h, "docs", "work", "a.pdf"), "~/docs/work/a.pdf"}, + {"/srv/share/a.pdf", "/srv/share/a.pdf"}, + } { + if got := displayOriginal(tt.orig, root); got != tt.want { + t.Errorf("displayOriginal(%q) = %q, want %q", tt.orig, got, tt.want) + } + } +} |
