feat: add download mode option (Track/Album) for Deezer downloads

Closes #10
This commit is contained in:
V1ck3s
2026-01-06 22:50:30 +01:00
committed by Vickes
parent 3fd98ea3de
commit 5d03f86872
7 changed files with 191 additions and 2 deletions

View File

@@ -53,7 +53,7 @@ public class DeezerDownloadServiceTests : IDisposable
}
}
private DeezerDownloadService CreateService(string? arl = null)
private DeezerDownloadService CreateService(string? arl = null, DownloadMode downloadMode = DownloadMode.Track)
{
var config = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string?>
@@ -64,11 +64,17 @@ public class DeezerDownloadServiceTests : IDisposable
})
.Build();
var subsonicSettings = Options.Create(new SubsonicSettings
{
DownloadMode = downloadMode
});
return new DeezerDownloadService(
_httpClientFactoryMock.Object,
config,
_localLibraryServiceMock.Object,
_metadataServiceMock.Object,
subsonicSettings,
_loggerMock.Object);
}
@@ -162,6 +168,42 @@ public class DeezerDownloadServiceTests : IDisposable
Assert.Equal("Song not found", exception.Message);
}
[Fact]
public void DownloadRemainingAlbumTracksInBackground_WithUnsupportedProvider_DoesNotThrow()
{
// Arrange
var service = CreateService(arl: "test-arl", downloadMode: DownloadMode.Album);
// Act & Assert - Should not throw, just log warning
service.DownloadRemainingAlbumTracksInBackground("spotify", "123456", "789");
}
[Fact]
public void DownloadRemainingAlbumTracksInBackground_WithDeezerProvider_StartsBackgroundTask()
{
// Arrange
_metadataServiceMock
.Setup(s => s.GetAlbumAsync("deezer", "123456"))
.ReturnsAsync(new Album
{
Id = "ext-deezer-album-123456",
Title = "Test Album",
Songs = new List<Song>
{
new Song { ExternalId = "111", Title = "Track 1" },
new Song { ExternalId = "222", Title = "Track 2" }
}
});
var service = CreateService(arl: "test-arl", downloadMode: DownloadMode.Album);
// Act - Should not throw (fire-and-forget)
service.DownloadRemainingAlbumTracksInBackground("deezer", "123456", "111");
// Assert - Just verify it doesn't throw, actual download is async
Assert.True(true);
}
}
/// <summary>