mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-08 22:36:37 +08:00
初始化
初始化项目
This commit is contained in:
@@ -116,47 +116,3 @@ func TestScrapeCandidateRowsPrioritizeLibraryArtworkBeforeEpisodes(t *testing.T)
|
||||
t.Fatalf("scrape order = [%s, %s], want series-level row before episode row", got[0].ID, got[1].ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnrichLibraryIncludesMergedCloudLibraryMedia(t *testing.T) {
|
||||
scraper, repos, closeServer := newTestScraper(t)
|
||||
defer closeServer()
|
||||
|
||||
local := model.Library{Name: "番剧", Path: t.TempDir(), Type: "tv", Enabled: true}
|
||||
cloud := model.Library{
|
||||
Name: "OpenList · 番剧",
|
||||
Path: BuildCloudLibraryPath("openlist", "/番剧", "/番剧"),
|
||||
Type: "tv",
|
||||
Enabled: true,
|
||||
}
|
||||
if err := repos.DB.Create(&local).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := repos.DB.Create(&cloud).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := repos.DB.Create(&model.Media{
|
||||
LibraryID: cloud.ID,
|
||||
Title: "间谍过家家",
|
||||
Path: "cloud://openlist/番剧/间谍过家家 - S02E02.mkv",
|
||||
SeasonNum: 2,
|
||||
EpisodeNum: 2,
|
||||
ScrapeStatus: "pending",
|
||||
}).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
result, err := scraper.EnrichLibraryDetailed(t.Context(), local.ID, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result.Matched != 1 || result.Processed != 1 || result.Candidates != 1 || result.Failed != 0 {
|
||||
t.Fatalf("result=%+v, want merged cloud media to be scraped once", result)
|
||||
}
|
||||
var got model.Media
|
||||
if err := repos.DB.First(&got, "library_id = ?", cloud.ID).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got.ScrapeStatus != "matched" || got.TMDbID != 12345 {
|
||||
t.Fatalf("merged cloud media was not enriched: status=%q tmdb=%d", got.ScrapeStatus, got.TMDbID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user