//go:build linux || darwin || freebsd || windows package command import "testing" func Test_volumeName(t *testing.T) { tests := []struct { name string filer string filerMountRootPath string dir string expected string }{ { name: "a drive letter leaves only the filer to fall back on", filer: "127.0.0.1:8888", filerMountRootPath: "/", dir: "S:", expected: "127.0.0.1:8888", }, { name: "empty path falls back to the filer", filer: "127.0.0.1:8888", filerMountRootPath: "", expected: "127.0.0.1:8888", }, { name: "several filers stay parseable as one option", filer: "127.0.0.1:8888,127.0.0.1:8889", filerMountRootPath: "/", expected: "127.0.0.1:8888+127.0.0.1:8889", }, { name: "a whole-tree mount takes the name of its network share", filer: "127.0.0.1:8888", filerMountRootPath: "/", dir: `\\seaweedfs\Images`, expected: "Images", }, { name: "a whole-tree mount takes the name of its directory", filer: "127.0.0.1:8888", filerMountRootPath: "/", dir: "/mnt/seaweedfs", expected: "seaweedfs", }, { name: "the mounted path outranks the mount point", filer: "127.0.0.1:8888", filerMountRootPath: "/buckets/videos", dir: "/mnt/seaweedfs", expected: "videos", }, { name: "a relative mount point is not a name", filer: "127.0.0.1:8888", filerMountRootPath: "/", dir: ".", expected: "127.0.0.1:8888", }, { name: "mounted directory names the disk", filer: "127.0.0.1:8888", filerMountRootPath: "/buckets/images", expected: "images", }, { name: "trailing slash is not a name", filer: "127.0.0.1:8888", filerMountRootPath: "/buckets/videos/", expected: "videos", }, { name: "spaces are kept, commas are not", filer: "127.0.0.1:8888", filerMountRootPath: "/Image, Disk", expected: "Image+ Disk", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := volumeName(tt.filer, tt.filerMountRootPath, tt.dir); got != tt.expected { t.Errorf("volumeName(%q, %q, %q) = %q, want %q", tt.filer, tt.filerMountRootPath, tt.dir, got, tt.expected) } }) } }