mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-07 05:46:38 +08:00
初始化
初始化项目
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@@ -34,48 +33,6 @@ func TestOrganizeDirectoryUsesConfiguredSourceWhenRequestSourceEmpty(t *testing.
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrganizeDirectorySkipsActiveQBitTorrentDownloads(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
src := filepath.Join(root, "downloads")
|
||||
dest := filepath.Join(root, "media")
|
||||
active := filepath.Join(src, "Still.Downloading.2026.1080p.mkv")
|
||||
done := filepath.Join(src, "Dune 2021 2160p WEB-DL.mkv")
|
||||
writeOrgFile(t, active, "partial")
|
||||
writeOrgFile(t, done, "done")
|
||||
|
||||
org := NewOrganizerService(&config.Config{}, zap.NewNop(), newOrganizerTestRepo(t))
|
||||
org.SetActiveDownloadProvider(func(context.Context) []QBitTorrent {
|
||||
return []QBitTorrent{{
|
||||
Hash: "active",
|
||||
Name: "Still.Downloading.2026.1080p",
|
||||
State: "downloading",
|
||||
Progress: 0.42,
|
||||
SavePath: src,
|
||||
ContentPath: active,
|
||||
}}
|
||||
})
|
||||
res, err := org.OrganizeDirectory(t.Context(), OrganizeOptions{
|
||||
SourcePath: src,
|
||||
DestPath: dest,
|
||||
TransferMode: TransferMove,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("organize directory: %v", err)
|
||||
}
|
||||
if res.Organized != 1 || res.Skipped != 1 {
|
||||
t.Fatalf("result = %+v, want organized=1 skipped=1", res)
|
||||
}
|
||||
if _, err := os.Stat(active); err != nil {
|
||||
t.Fatalf("active qB file must stay in source: %v", err)
|
||||
}
|
||||
for _, item := range res.Items {
|
||||
if item.Source == active && item.Action == "skip" && item.Reason == organizeSkipActiveDownload {
|
||||
return
|
||||
}
|
||||
}
|
||||
t.Fatalf("missing active-download skip item: %+v", res.Items)
|
||||
}
|
||||
|
||||
func TestOrganizeDirectoryMapsConfiguredHostPathsToContainerPaths(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
hostDownloads := filepath.Join(root, "nas-host", "downloads")
|
||||
|
||||
Reference in New Issue
Block a user