Skip to content

Commit

Permalink
Add/license url override (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
pymenguy authored Feb 3, 2025
1 parent 92a3165 commit d503079
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

namespace NuGetUtility.PackageInformationReader
{
public record struct CustomPackageInformation(string Id, INuGetVersion Version, string License, string? Copyright = null, string? Authors = null, string? Title = null, string? ProjectUrl = null, string? Summary = null, string? Description = null);
public record struct CustomPackageInformation(string Id, INuGetVersion Version, string License, Uri? LicenseUrl = null, string? Copyright = null, string? Authors = null, string? Title = null, string? ProjectUrl = null, string? Summary = null, string? Description = null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public PackageMetadata(PackageIdentity identity, LicenseType licenseType, Custom

public string? Title => CustomPackageInformation?.Title;

public Uri? LicenseUrl => null;
public Uri? LicenseUrl => CustomPackageInformation?.LicenseUrl;

public string? ProjectUrl => CustomPackageInformation?.ProjectUrl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private static void CheckResult(ReferencedPackageWithContext[] result,
Assert.That(packages, Is.EquivalentTo(result.Select(s => new CustomPackageInformation(s.PackageInfo.Identity.Id,
s.PackageInfo.Identity.Version,
s.PackageInfo.LicenseMetadata!.License,
s.PackageInfo.LicenseUrl,
s.PackageInfo.Copyright,
s.PackageInfo.Authors,
s.PackageInfo.Title,
Expand Down Expand Up @@ -125,6 +126,7 @@ public async Task GetPackageInfo_Should_PreferLocalPackageCacheOverRepositories(
mockedInfo.Summary.Returns(info.Summary);
mockedInfo.Description.Returns(info.Description);
mockedInfo.LicenseMetadata.Returns(new LicenseMetadata(LicenseType.Expression, info.License));
mockedInfo.LicenseUrl.Returns(info.LicenseUrl);
_globalPackagesFolderUtility.GetPackage(identity).Returns(mockedInfo);

return identity;
Expand All @@ -147,6 +149,7 @@ private static void SetupPackagesForRepositories(IEnumerable<CustomPackageInform
IPackageMetadata resultingInfo = Substitute.For<IPackageMetadata>();
resultingInfo.Identity.Returns(new PackageIdentity(package.Id, package.Version));
resultingInfo.LicenseMetadata.Returns(new LicenseMetadata(LicenseType.Expression, package.License));
resultingInfo.LicenseUrl.Returns(package.LicenseUrl);
resultingInfo.Copyright.Returns(package.Copyright);
resultingInfo.Authors.Returns(package.Authors);
resultingInfo.Title.Returns(package.Title);
Expand Down

0 comments on commit d503079

Please sign in to comment.