mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 19:36:36 +08:00
22b64d3d47
feat(bot): button menu, capacity/open-reg quota, redemption codes, user mgmt, account expiry + signin streak, device anti-sharing + inactivity cleanup, one-click kick, self-service username/password - Consolidate organize/rename defaults into Tools panel Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
43 lines
1.4 KiB
Go
43 lines
1.4 KiB
Go
package service
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestResolveAccessibleLibraryPathMapsConfiguredHostMediaDir(t *testing.T) {
|
|
root := t.TempDir()
|
|
hostRoot := filepath.Join(root, "nas", "host", "media")
|
|
containerRoot := filepath.Join(root, "container", "media")
|
|
containerLibrary := filepath.Join(containerRoot, "电视剧", "国产剧")
|
|
if err := os.MkdirAll(containerLibrary, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Setenv("MEDIASTATION_MEDIA_DIR", hostRoot)
|
|
t.Setenv("MEDIASTATION_MEDIA_CONTAINER_DIR", containerRoot)
|
|
|
|
got, err := resolveAccessibleLibraryPath(filepath.Join(hostRoot, "电视剧", "国产剧"))
|
|
if err != nil {
|
|
t.Fatalf("resolveAccessibleLibraryPath() error = %v", err)
|
|
}
|
|
if got != filepath.Clean(containerLibrary) {
|
|
t.Fatalf("resolveAccessibleLibraryPath() = %q, want %q", got, filepath.Clean(containerLibrary))
|
|
}
|
|
}
|
|
|
|
func TestResolveAccessibleLibraryPathKeepsAccessibleContainerPath(t *testing.T) {
|
|
containerLibrary := filepath.Join(t.TempDir(), "media", "电影")
|
|
if err := os.MkdirAll(containerLibrary, 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
got, err := resolveAccessibleLibraryPath(containerLibrary)
|
|
if err != nil {
|
|
t.Fatalf("resolveAccessibleLibraryPath() error = %v", err)
|
|
}
|
|
if got != filepath.Clean(containerLibrary) {
|
|
t.Fatalf("resolveAccessibleLibraryPath() = %q, want %q", got, filepath.Clean(containerLibrary))
|
|
}
|
|
}
|