mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 03:26:37 +08:00
b0fe40142a
* Rebrand MMTL to MeBox across codebase and assets Rename the project display name, Go module path, environment variable prefix (MEBOX_*), Docker image references, and UI branding from MMTL/mmtl to MeBox/mebox. Replace logo assets with the new MeBox icon and keep legacy SQLite migration support for existing mmtl.db deployments. Co-authored-by: truewhile <truewhile@users.noreply.github.com> * Fix logo icons: use cube-only crop without truncated text Previous icon generation cropped too much of the source image, including partial MeBox wordmark text that was cut off in square icon containers. Regenerate logo-64/192/512, favicon, and SVG from cube-only region. Co-authored-by: truewhile <truewhile@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: truewhile <truewhile@users.noreply.github.com>
55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
package service
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/truewhile/MeBox/internal/model"
|
|
"github.com/truewhile/MeBox/internal/repository"
|
|
)
|
|
|
|
func TestNormalizeLocalLibraryPathsRewritesRelativeDockerMediaRoot(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("MEBOX_MEDIA_CONTAINER_DIR", containerRoot)
|
|
|
|
db := newServiceTestDB(t, &model.Library{}, &model.LibraryRoot{}, &model.Media{})
|
|
repos := repository.New(db)
|
|
lib := model.Library{Name: "国产剧", Path: filepath.Join("media", "电视剧", "国产剧"), Type: "tv", Enabled: true}
|
|
if err := repos.Library.CreateWithRoots(t.Context(), &lib, []model.LibraryRoot{{
|
|
Name: "国产剧",
|
|
Path: filepath.Join("media", "电视剧", "国产剧"),
|
|
Enabled: true,
|
|
}}); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
svc := &Container{Repo: repos}
|
|
if err := svc.NormalizeLocalLibraryPaths(t.Context()); err != nil {
|
|
t.Fatalf("NormalizeLocalLibraryPaths() error = %v", err)
|
|
}
|
|
|
|
got, err := repos.Library.FindByID(t.Context(), lib.ID)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
want := filepath.Clean(containerLibrary)
|
|
if got.Path != want {
|
|
t.Fatalf("library path = %q, want %q", got.Path, want)
|
|
}
|
|
if len(got.Roots) != 1 || got.Roots[0].Path != want {
|
|
t.Fatalf("library roots = %#v, want path %q", got.Roots, want)
|
|
}
|
|
}
|
|
|
|
func TestNormalizePersistedLocalLibraryPathKeepsEmptyPathEmpty(t *testing.T) {
|
|
if got := normalizePersistedLocalLibraryPath(""); got != "" {
|
|
t.Fatalf("normalizePersistedLocalLibraryPath(empty) = %q, want empty", got)
|
|
}
|
|
}
|