Use `All()` for import lists in ImportListSyncService

pull/4124/head
Bogdan 1 year ago
parent f9b8d7720c
commit 78610ff6ee

@ -28,10 +28,6 @@ namespace NzbDrone.Core.Test.ImportListTests
_importListReports = new List<ImportListItemInfo> { importListItem1 }; _importListReports = new List<ImportListItemInfo> { importListItem1 };
Mocker.GetMock<IFetchAndParseImportList>()
.Setup(v => v.Fetch())
.Returns(_importListReports);
Mocker.GetMock<ISearchForNewArtist>() Mocker.GetMock<ISearchForNewArtist>()
.Setup(v => v.SearchForNewArtist(It.IsAny<string>())) .Setup(v => v.SearchForNewArtist(It.IsAny<string>()))
.Returns(new List<Artist>()); .Returns(new List<Artist>());
@ -41,8 +37,8 @@ namespace NzbDrone.Core.Test.ImportListTests
.Returns(new List<Album>()); .Returns(new List<Album>());
Mocker.GetMock<IImportListFactory>() Mocker.GetMock<IImportListFactory>()
.Setup(v => v.Get(It.IsAny<int>())) .Setup(v => v.All())
.Returns(new ImportListDefinition { ShouldMonitor = ImportListMonitorType.SpecificAlbum }); .Returns(new List<ImportListDefinition> { new () { ShouldMonitor = ImportListMonitorType.SpecificAlbum } });
Mocker.GetMock<IFetchAndParseImportList>() Mocker.GetMock<IFetchAndParseImportList>()
.Setup(v => v.Fetch()) .Setup(v => v.Fetch())
@ -145,8 +141,8 @@ namespace NzbDrone.Core.Test.ImportListTests
private void WithListSettings(ImportListMonitorType monitor = ImportListMonitorType.EntireArtist, bool shouldMonitorExisting = false, bool shouldSearch = true) private void WithListSettings(ImportListMonitorType monitor = ImportListMonitorType.EntireArtist, bool shouldMonitorExisting = false, bool shouldSearch = true)
{ {
Mocker.GetMock<IImportListFactory>() Mocker.GetMock<IImportListFactory>()
.Setup(v => v.Get(It.IsAny<int>())) .Setup(v => v.All())
.Returns(new ImportListDefinition { ShouldMonitor = monitor, ShouldMonitorExisting = shouldMonitorExisting, ShouldSearch = shouldSearch }); .Returns(new List<ImportListDefinition> { new () { ShouldMonitor = monitor, ShouldMonitorExisting = shouldMonitorExisting, ShouldSearch = shouldSearch } });
} }
[Test] [Test]

@ -100,12 +100,13 @@ namespace NzbDrone.Core.ImportLists
var reportNumber = 1; var reportNumber = 1;
var listExclusions = _importListExclusionService.All().ToDictionary(x => x.ForeignId); var listExclusions = _importListExclusionService.All().ToDictionary(x => x.ForeignId);
var importLists = _importListFactory.All();
foreach (var item in items) foreach (var item in items)
{ {
_logger.ProgressTrace("Processing list item {0}/{1}", reportNumber++, items.Count); _logger.ProgressTrace("Processing list item {0}/{1}", reportNumber++, items.Count);
var importList = _importListFactory.Get(item.ImportListId); var importList = importLists.Single(x => x.Id == item.ImportListId);
if (item.Album.IsNotNullOrWhiteSpace() || item.AlbumMusicBrainzId.IsNotNullOrWhiteSpace()) if (item.Album.IsNotNullOrWhiteSpace() || item.AlbumMusicBrainzId.IsNotNullOrWhiteSpace())
{ {

Loading…
Cancel
Save