Files
seaweedfs/weed/command/mount_common_test.go
T
Chris LuandGitHub 7658305c76 mount: name the disk after the mounted path (#10958)
* mount: name the disk after the mounted path

Finder and Explorer labelled every mount with the filer address, so two
mounts from one filer were indistinguishable. Use the mounted path's last
segment, the way df already shows it, and keep the filer address only for
a whole-tree mount.

* mount: let a given mount option override the default

The options from -o were placed before the ones this mount derives, so
a volname or iosize given on the command line lost to the derived value.
Append them last, matching the Windows adapter.

* mount: document what labels the disk
2026-08-25 22:56:33 -07:00

59 lines
1.6 KiB
Go

//go:build linux || darwin || freebsd || windows
package command
import "testing"
func Test_volumeName(t *testing.T) {
tests := []struct {
name string
filer string
filerMountRootPath string
expected string
}{
{
name: "whole tree falls back to the filer",
filer: "127.0.0.1:8888",
filerMountRootPath: "/",
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: "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); got != tt.expected {
t.Errorf("volumeName(%q, %q) = %q, want %q", tt.filer, tt.filerMountRootPath, got, tt.expected)
}
})
}
}