mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-28 04:12:07 +02:00
fix(download): suffix only colliding quality variants
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package gobackend
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestShouldReuseExistingOutputProtectsCompletedFile(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "Artist - Track.flac")
|
||||
if err := os.WriteFile(path, []byte("existing audio"), 0o644); err != nil {
|
||||
t.Fatalf("write existing output: %v", err)
|
||||
}
|
||||
|
||||
if !shouldReuseExistingOutput(DownloadRequest{}, path) {
|
||||
t.Fatal("expected completed output to be reused when variants are disabled")
|
||||
}
|
||||
if shouldReuseExistingOutput(
|
||||
DownloadRequest{AllowQualityVariant: true},
|
||||
path,
|
||||
) {
|
||||
t.Fatal("quality-variant staging output must remain independently writable")
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldReuseExistingOutputIgnoresEmptyStagingFile(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "native_saf_work.flac")
|
||||
if err := os.WriteFile(path, nil, 0o644); err != nil {
|
||||
t.Fatalf("write staging output: %v", err)
|
||||
}
|
||||
|
||||
if shouldReuseExistingOutput(DownloadRequest{}, path) {
|
||||
t.Fatal("empty staging output must not be treated as a completed download")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user