Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.
/ NuGet.Jobs Public archive

Commit

Permalink
#2504 Remove package2catalog job and all code only used by this job (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierdecoster authored Jun 12, 2019
1 parent 711ecf4 commit f981490
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 355 deletions.
28 changes: 0 additions & 28 deletions src/Catalog/Helpers/FeedHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web;
Expand Down Expand Up @@ -34,33 +33,6 @@ public static Uri MakeUriForPackage(string source, string id, string version)
return UriUtils.GetNonhijackableUri(uri);
}

/// <summary>
/// Returns a <see cref="SortedList{DateTime, IList{FeedPackageDetails}}"/> from the feed.
/// </summary>
/// <param name="keyDateFunc">The <see cref="DateTime"/> field to sort the <see cref="FeedPackageDetails"/> on.</param>
public static async Task<SortedList<DateTime, IList<FeedPackageDetails>>> GetPackagesInOrder(HttpClient client, Uri uri, Func<FeedPackageDetails, DateTime> keyDateFunc)
{
var result = new SortedList<DateTime, IList<FeedPackageDetails>>();

var allPackages = await GetPackages(client, uri);

foreach (var package in allPackages)
{
IList<FeedPackageDetails> packagesWithSameKeyDate;

var packageKeyDate = keyDateFunc(package);
if (!result.TryGetValue(packageKeyDate, out packagesWithSameKeyDate))
{
packagesWithSameKeyDate = new List<FeedPackageDetails>();
result.Add(packageKeyDate, packagesWithSameKeyDate);
}

packagesWithSameKeyDate.Add(package);
}

return result;
}

/// <summary>
/// Asynchronously gets a <see cref="IList{FeedPackageDetails}"/> from the feed.
/// </summary>
Expand Down
141 changes: 0 additions & 141 deletions src/Ng/Jobs/Package2CatalogJob.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Ng/Ng.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
<Compile Include="Jobs\Monitoring2MonitoringJob.cs" />
<Compile Include="Jobs\MonitoringProcessorJob.cs" />
<Compile Include="Jobs\NgJob.cs" />
<Compile Include="Jobs\Package2CatalogJob.cs" />
<Compile Include="Json\RegistrationBaseUrlRewritingJsonReader.cs" />
<Compile Include="Json\InterceptingJsonReader.cs" />
<Compile Include="Json\JTokenExtensions.cs" />
Expand Down
1 change: 0 additions & 1 deletion src/Ng/NgJobFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public static class NgJobFactory
{
public static IDictionary<string, Type> JobMap = new Dictionary<string, Type>()
{
{ "package2catalog", typeof(Package2CatalogJob) },
{ "db2catalog", typeof(Db2CatalogJob) },
{ "catalog2registration", typeof(Catalog2RegistrationJob) },
{ "catalog2lucene", typeof(Catalog2LuceneJob) },
Expand Down
63 changes: 0 additions & 63 deletions tests/CatalogTests/Helpers/FeedHelpersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
Expand Down Expand Up @@ -52,75 +51,13 @@ public async Task GetPackages_GetsAllPackages(IEnumerable<ODataPackage> oDataPac
}
}

public static IEnumerable<object[]> GetPackagesInOrder_GetsAllPackagesInOrder_data
{
get
{
var oDataPackages = ODataPackages;

var keyDateFuncs = new Func<FeedPackageDetails, DateTime>[]
{
package => package.CreatedDate,
package => package.LastEditedDate,
package => package.PublishedDate,
};

return keyDateFuncs.Select(p => new object[] { oDataPackages, p });
}
}

[Theory]
[MemberData(nameof(GetPackagesInOrder_GetsAllPackagesInOrder_data))]
public async Task GetPackagesInOrder_GetsAllPackagesInOrder(IEnumerable<ODataPackage> oDataPackages, Func<FeedPackageDetails, DateTime> keyDateFunc)
{
//// Act
var feedPackagesInOrder = await TestGetPackagesInOrder(oDataPackages, keyDateFunc);

//// Assert
// All OData packages must exist in the result.
foreach (var oDataPackage in oDataPackages)
{
Assert.Contains(feedPackagesInOrder.SelectMany(p => p.Value),
(feedPackage) =>
{
return ArePackagesEqual(feedPackage, oDataPackage);
});
}

// The packages must be in order and grouped by timestamp.
var currentTimestamp = DateTime.MinValue;
foreach (var feedPackages in feedPackagesInOrder)
{
Assert.True(currentTimestamp < feedPackages.Key);

currentTimestamp = feedPackages.Key;
foreach (var feedPackage in feedPackages.Value)
{
var packageKeyDate = keyDateFunc(feedPackage);
Assert.Equal(packageKeyDate.Ticks, currentTimestamp.Ticks);

VerifyDateTimesAreInUtc(feedPackage);
}
}
}

private Task<IList<FeedPackageDetails>> TestGetPackagesAsync(IEnumerable<ODataPackage> oDataPackages)
{
return FeedHelpers.GetPackages(
new HttpClient(GetMessageHandlerForPackages(oDataPackages)),
new Uri(_baseUri + "/test"));
}

private Task<SortedList<DateTime, IList<FeedPackageDetails>>> TestGetPackagesInOrder(
IEnumerable<ODataPackage> oDataPackages,
Func<FeedPackageDetails, DateTime> keyDateFunc)
{
return FeedHelpers.GetPackagesInOrder(
new HttpClient(GetMessageHandlerForPackages(oDataPackages)),
new Uri(_baseUri + "/test"),
keyDateFunc);
}

private HttpMessageHandler GetMessageHandlerForPackages(IEnumerable<ODataPackage> oDataPackages)
{
var mockServer = new MockServerHttpClientHandler();
Expand Down
1 change: 0 additions & 1 deletion tests/NgTests/NgTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
<Compile Include="JobNameTelemetryInitializerTests.cs" />
<Compile Include="JobPropertiesTelemetryInitializerTests.cs" />
<Compile Include="NgJobFactoryTests.cs" />
<Compile Include="Package2CatalogJobTests.cs" />
<Compile Include="PackageFixup\FixPackageHashHandlerFacts.cs" />
<Compile Include="PackageFixup\PackagesContainerCatalogProcessorFacts.cs" />
<Compile Include="PackageFixup\ValidatePackageHashHandlerFacts.cs" />
Expand Down
Loading

0 comments on commit f981490

Please sign in to comment.