mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-28 11:16: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>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/truewhile/MeBox/internal/model"
|
|
)
|
|
|
|
func TestEmbyLatestItemsCollapsesMovieVersions(t *testing.T) {
|
|
svc := newTestEmbyService(t)
|
|
lib := model.Library{Name: "电影", Path: `/media/movies`, Type: "movie", Enabled: true}
|
|
if err := svc.repo.Library.Create(t.Context(), &lib); err != nil {
|
|
t.Fatalf("create library: %v", err)
|
|
}
|
|
now := time.Now()
|
|
for _, media := range []model.Media{
|
|
{
|
|
Base: model.Base{ID: "dune-1080", CreatedAt: now.Add(time.Minute)},
|
|
LibraryID: lib.ID,
|
|
Title: "Dune",
|
|
Year: 2021,
|
|
TMDbID: 438631,
|
|
Path: `/media/movies/Dune.2021.1080p.mkv`,
|
|
Width: 1920,
|
|
SizeBytes: 100,
|
|
},
|
|
{
|
|
Base: model.Base{ID: "dune-2160", CreatedAt: now.Add(2 * time.Minute)},
|
|
LibraryID: lib.ID,
|
|
Title: "Dune",
|
|
Year: 2021,
|
|
TMDbID: 438631,
|
|
Path: `/media/movies/Dune.2021.2160p.mkv`,
|
|
Width: 3840,
|
|
SizeBytes: 200,
|
|
},
|
|
{
|
|
Base: model.Base{ID: "matrix", CreatedAt: now},
|
|
LibraryID: lib.ID,
|
|
Title: "The Matrix",
|
|
Year: 1999,
|
|
TMDbID: 603,
|
|
Path: `/media/movies/The.Matrix.1999.mkv`,
|
|
},
|
|
} {
|
|
if err := svc.repo.DB.Create(&media).Error; err != nil {
|
|
t.Fatalf("create media: %v", err)
|
|
}
|
|
}
|
|
|
|
latest, err := svc.LatestItems(t.Context(), "user-1", lib.ID, 10)
|
|
if err != nil {
|
|
t.Fatalf("latest items: %v", err)
|
|
}
|
|
if len(latest) != 2 {
|
|
t.Fatalf("latest items = %#v, want Dune collapsed plus Matrix", latest)
|
|
}
|
|
if latest[0]["Id"] != "dune-2160" {
|
|
t.Fatalf("latest first item = %#v, want best Dune version", latest[0])
|
|
}
|
|
sources := latest[0]["MediaSources"].([]map[string]any)
|
|
if len(sources) != 2 {
|
|
t.Fatalf("collapsed latest item should expose both versions, got %#v", sources)
|
|
}
|
|
}
|