package utils
import (
"testing"
)
func TestStripMountPoint(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{"macOS volume", "/Volumes/ExternalDrive/Audio", "ExternalDrive/Audio"},
{"macOS root volume", "/Volumes/Drive", "Drive"},
{"Linux media mount", "/media/david/USB-Drive/Audio", "USB-Drive/Audio"},
{"Linux media different user", "/media/john/Backup/Audio", "Backup/Audio"},
{"Linux media Pomona", "/media/david/Pomona-4/Pomona/A05/2025-11-08", "Pomona-4/Pomona/A05/2025-11-08"},
{"Linux mnt mount", "/mnt/storage/Audio", "storage/Audio"},
{"Absolute no mount", "/home/user/Audio", "/home/user/Audio"},
{"Relative path", "./relative/path", "relative/path"},
{"Root", "/", "/"},
{"Empty", "", "."},
{"Volumes only", "/Volumes/", "."},
{"Media with user only", "/media/david/", "."},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := StripMountPoint(tt.input)
if result != tt.expected {
t.Errorf("StripMountPoint(%q) = %q, want %q", tt.input, result, tt.expected)
}
})
}
}
func TestNormalizeFolderPath(t *testing.T) {
tests := []struct {
name string
input string
expected string
}{
{"Linux media path", "/media/david/Pomona-4/Pomona/A05/2025-11-08/", "Pomona-4/Pomona/A05/2025-11-08"},
{"macOS volumes path", "/Volumes/Drive/Audio/Recordings/", "Drive/Audio/Recordings"},
{"Linux mnt path", "/mnt/storage/Audio/Files/", "storage/Audio/Files"},
{"With trailing slash", "/media/david/USB/Audio/", "USB/Audio"},
{"Without trailing slash", "/media/david/USB/Audio", "USB/Audio"},
{"Deep nested path", "/media/david/Pomona-4/Level1/Level2/Level3/", "Pomona-4/Level1/Level2/Level3"},
{"File at mount root", "/media/david/", "."},
{"Volumes with drive only", "/Volumes/Drive/", "Drive"},
{"Volumes drive no trailing slash", "/Volumes/Drive", "Drive"},
{"Root", "/", ""},
{"Empty", "", "."},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := NormalizeFolderPath(tt.input)
if result != tt.expected {
t.Errorf("NormalizeFolderPath(%q) = %q, want %q", tt.input, result, tt.expected)
}
})
}
}