// SPDX-License-Identifier: GPL-3.0-or-later package engine import ( "path/filepath" "testing" ) // 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) } } }