public async Task Search404NonMergeFailureIsNotApplicable() { IndexingResults.Add(new IndexingResult(key: "search-doc", statusCode: 404)); AllIndexActions.Add(new IdAndValue <IndexActions>( "NuGet.Versioning", new IndexActions( search: new List <IndexAction <KeyedDocument> > { IndexAction.Delete(new KeyedDocument { Key = "search-doc" }), }, hijack: new List <IndexAction <KeyedDocument> >(), versionListDataResult: new ResultAndAccessCondition <VersionListData>( new VersionListData(new Dictionary <string, VersionPropertiesData>()), Mock.Of <IAccessCondition>())))); var result = await Target.TryFixUpAsync(ItemList, AllIndexActions, Exception); Assert.False(result.Applicable); }
public async Task Search404MergeFailureIsApplicable() { ItemList.Add(new CatalogCommitItem( new Uri("https://example/catalog/0.json"), "commit-id-a", new DateTime(2020, 3, 16, 12, 5, 0, DateTimeKind.Utc), new string[0], new[] { Schema.DataTypes.PackageDetails }, new PackageIdentity("NuGet.Frameworks", NuGetVersion.Parse("1.0.0")))); ItemList.Add(new CatalogCommitItem( new Uri("https://example/catalog/1.json"), "commit-id-a", new DateTime(2020, 3, 16, 12, 5, 0, DateTimeKind.Utc), new string[0], new[] { Schema.DataTypes.PackageDetails }, new PackageIdentity("NuGet.Versioning", NuGetVersion.Parse("0.9.0-beta.1")))); IndexingResults.Add(new IndexingResult(key: "search-doc", statusCode: 404)); AllIndexActions.Add(new IdAndValue <IndexActions>( "NuGet.Versioning", new IndexActions( search: new List <IndexAction <KeyedDocument> > { IndexAction.Merge(new KeyedDocument { Key = "search-doc" }), }, hijack: new List <IndexAction <KeyedDocument> >(), versionListDataResult: new ResultAndAccessCondition <VersionListData>( new VersionListData(new Dictionary <string, VersionPropertiesData>()), Mock.Of <IAccessCondition>())))); VersionListClient .Setup(x => x.ReadAsync(It.IsAny <string>())) .ReturnsAsync(() => new ResultAndAccessCondition <VersionListData>( new VersionListData(new Dictionary <string, VersionPropertiesData> { { "1.0.0", new VersionPropertiesData(listed: true, semVer2: false) }, }), Mock.Of <IAccessCondition>())); var leaf = new PackageDetailsCatalogLeaf { Url = "https://example/catalog/2.json", CommitId = "commit-id", CommitTimestamp = new DateTimeOffset(2020, 3, 17, 12, 5, 0, TimeSpan.Zero), Type = CatalogLeafType.PackageDetails, }; LeafFetcher .Setup(x => x.GetLatestLeavesAsync( It.IsAny <string>(), It.IsAny <IReadOnlyList <IReadOnlyList <NuGetVersion> > >())) .ReturnsAsync(() => new LatestCatalogLeaves( new HashSet <NuGetVersion>(), new Dictionary <NuGetVersion, PackageDetailsCatalogLeaf> { { NuGetVersion.Parse("1.0.0"), leaf }, })); var result = await Target.TryFixUpAsync(ItemList, AllIndexActions, Exception); Assert.True(result.Applicable, "The fix up should be applicable."); Assert.Equal(3, result.ItemList.Count); Assert.Empty(ItemList.Except(result.ItemList)); var addedItem = Assert.Single(result.ItemList.Except(ItemList)); Assert.Equal(leaf.Url, addedItem.Uri.AbsoluteUri); Assert.Equal(leaf.CommitId, addedItem.CommitId); Assert.Equal(leaf.CommitTimestamp, addedItem.CommitTimeStamp); Assert.Empty(addedItem.Types); Assert.Equal(Schema.DataTypes.PackageDetails, Assert.Single(addedItem.TypeUris)); Assert.Equal(new PackageIdentity("NuGet.Versioning", NuGetVersion.Parse("1.0.0")), addedItem.PackageIdentity); Assert.True(addedItem.IsPackageDetails, "The generated item should be a package details item."); Assert.False(addedItem.IsPackageDelete, "The generated item should not be a package delete item."); }