Files
MeBox/internal/service/service_library_normalize_test.go
truewhile b0fe40142a Rebrand MMTL to MeBox (name, logo, Docker image) (#17)
* 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>
2026-09-02 16:26:28 +08:00

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)
}
}