1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// 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)
}
}
}
|