mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-08 22:36:37 +08:00
fix docker media path normalization
This commit is contained in:
@@ -88,6 +88,24 @@ func TestResolveAccessibleLibraryPathKeepsAccessibleContainerPath(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveAccessibleLibraryPathMapsRelativeDockerMediaMarker(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
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_CONTAINER_DIR", containerRoot)
|
||||
|
||||
got, err := resolveAccessibleLibraryPath(filepath.Join("media", "电视剧", "国产剧"))
|
||||
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 TestInferLibraryKindFromCategoryPathOverridesMovieDefault(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
@@ -142,6 +160,26 @@ func TestResolveMappedDestinationPathPrefersConfiguredContainerMapping(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveMappedDestinationPathPrefersContainerForRelativeMediaMarker(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
workDir := filepath.Join(root, "work")
|
||||
containerMedia := filepath.Join(root, "container", "media")
|
||||
if err := os.MkdirAll(filepath.Join(workDir, "media", "电视剧", "国产剧"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.MkdirAll(filepath.Join(containerMedia, "电视剧", "国产剧"), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Chdir(workDir)
|
||||
t.Setenv("MEDIASTATION_MEDIA_CONTAINER_DIR", containerMedia)
|
||||
|
||||
got := resolveMappedDestinationPath(filepath.Join("media", "电视剧", "国产剧"))
|
||||
want := filepath.Join(containerMedia, "电视剧", "国产剧")
|
||||
if got != filepath.Clean(want) {
|
||||
t.Fatalf("resolveMappedDestinationPath() = %q, want %q", got, filepath.Clean(want))
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveAccessibleMappedPathMapsWindowsDownloadVariants(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
containerDownloads := filepath.Join(root, "container", "downloads")
|
||||
|
||||
Reference in New Issue
Block a user