Files
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

103 lines
2.7 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package service
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/truewhile/MeBox/internal/model"
)
func TestWriteMediaNFOUsesMappedDestinationPath(t *testing.T) {
root := t.TempDir()
t.Setenv("MEBOX_MEDIA_DIR", root)
t.Setenv("MEBOX_MEDIA_CONTAINER_DIR", "/media")
mediaPath := filepath.Join(root, "电影", "测试电影.mkv")
if err := os.MkdirAll(filepath.Dir(mediaPath), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(mediaPath, []byte("media"), 0o644); err != nil {
t.Fatal(err)
}
got, err := WriteMediaNFO(&model.Media{
Title: "测试电影",
Path: "/media/电影/测试电影.mkv",
Year: 2026,
})
if err != nil {
t.Fatal(err)
}
want := filepath.Join(root, "电影", "测试电影.nfo")
if got != want {
t.Fatalf("nfo path = %q, want %q", got, want)
}
if _, err := os.Stat(want); err != nil {
t.Fatal(err)
}
}
func TestWriteMediaNFOUsesEpisodeTitleForEpisodeDetails(t *testing.T) {
root := t.TempDir()
mediaPath := filepath.Join(root, "剧集", "间谍过家家", "Season 02", "间谍过家家 - S02E01.mkv")
if err := os.MkdirAll(filepath.Dir(mediaPath), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(mediaPath, []byte("media"), 0o644); err != nil {
t.Fatal(err)
}
got, err := WriteMediaNFO(&model.Media{
Title: "间谍过家家",
OriginalName: "SPY×FAMILY",
EpisodeTitle: "任务代号: 猫",
Path: mediaPath,
SeasonNum: 2,
EpisodeNum: 1,
})
if err != nil {
t.Fatal(err)
}
body, err := os.ReadFile(got)
if err != nil {
t.Fatal(err)
}
text := string(body)
if !strings.Contains(text, "<title>任务代号: 猫</title>") || !strings.Contains(text, "<showtitle>间谍过家家</showtitle>") {
t.Fatalf("episode nfo did not keep episode/show titles separate:\n%s", text)
}
}
func TestWriteMediaNFOAdultTitleWithCode(t *testing.T) {
root := t.TempDir()
mediaPath := filepath.Join(root, "成人", "IPZZ-090-测试成人影片", "IPZZ-090.mp4")
if err := os.MkdirAll(filepath.Dir(mediaPath), 0o755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(mediaPath, []byte("media"), 0o644); err != nil {
t.Fatal(err)
}
got, err := WriteMediaNFO(&model.Media{
Title: "测试成人影片",
OriginalName: "IPZZ-090",
Path: mediaPath,
NSFW: true,
})
if err != nil {
t.Fatal(err)
}
body, err := os.ReadFile(got)
if err != nil {
t.Fatal(err)
}
text := string(body)
if !strings.Contains(text, "<title>IPZZ-090-测试成人影片</title>") {
t.Fatalf("expected title with code at front in adult nfo, got:\n%s", text)
}
if !strings.Contains(text, "<originaltitle>IPZZ-090</originaltitle>") {
t.Fatalf("expected originaltitle with code, got:\n%s", text)
}
}