-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to NpmPackageManager to fime the time at which the first p…
…ackage version is created. (#460) * Add method to fetch when the package is first published. * Address PR comments. * Include repo metadata if set. * Added new argument to GetPackageMetadata base method. --------- Co-authored-by: Mounika Rendedla <[email protected]>
- Loading branch information
Showing
12 changed files
with
119 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,7 +337,38 @@ public async Task GetPublishedAtSucceeds(string purlString, string? expectedTime | |
Assert.AreEqual(DateTime.Parse(expectedTime), time); | ||
} | ||
} | ||
|
||
|
||
[DataTestMethod] | ||
[DataRow("pkg:npm/[email protected]", "2012-04-23T16:37:11.912")] | ||
[DataRow("pkg:npm/%40angular/[email protected]", "2016-04-28T04:23:30.108")] | ||
[DataRow("pkg:npm/[email protected]", "2018-08-06T12:04:34.792")] | ||
[DataRow("pkg:npm/[email protected]", "2018-12-19T23:29:18.197")] | ||
[DataRow("pkg:npm/[email protected]", "2022-03-04T05:57:01.108")] | ||
public async Task GetCreatedAtSucceeds(string purlString, string? expectedTime = null) | ||
{ | ||
PackageURL purl = new(purlString); | ||
var metadata = await _projectManager.Object.GetPackageMetadataAsync(purl, useCache: false); | ||
Assert.AreEqual(DateTime.Parse(expectedTime), metadata.CreatedTime); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow(true)] | ||
[DataRow(false)] | ||
public async Task FetchesRepositoryMetadataSuccessfully(bool includeRepositoryMetadata) | ||
{ | ||
PackageURL purl = new("pkg:npm/lodash.js"); | ||
var metadata = await _projectManager.Object.GetPackageMetadataAsync(purl, includeRepositoryMetadata: includeRepositoryMetadata); | ||
|
||
if(includeRepositoryMetadata) | ||
{ | ||
Assert.IsNotNull(metadata.Repository); | ||
} | ||
else | ||
{ | ||
Assert.IsNull(metadata.Repository); | ||
} | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("pkg:npm/[email protected]", "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz")] | ||
[DataRow("pkg:npm/%40angular/[email protected]", "https://registry.npmjs.org/%40angular/core/-/core-13.2.5.tgz")] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,7 +299,15 @@ public async Task GetPackagePrefixReservedSucceeds(string purlString, bool expec | |
|
||
Assert.AreEqual(expectedReserved, isReserved); | ||
} | ||
|
||
|
||
public async Task SkipsRepositoryMetadataFetchSuccessfully() | ||
{ | ||
PackageURL purl = new("pkg:nuget/[email protected]"); | ||
var metadata = await _projectManager.GetPackageMetadataAsync(purl, includeRepositoryMetadata: false); | ||
|
||
Assert.IsNull(metadata.Repository); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("pkg:nuget/[email protected]", | ||
"https://api.nuget.org/v3-flatcontainer/newtonsoft.json/13.0.1/newtonsoft.json.13.0.1.nupkg", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,6 +191,25 @@ public async Task DetailedPackageExistsAsync_WorksAsExpected(string purlString, | |
Assert.AreEqual(exists, existence.Exists); | ||
} | ||
|
||
|
||
[DataTestMethod] | ||
[DataRow(true)] | ||
[DataRow(false)] | ||
public async Task FetchesRepositoryMetadataSuccessfully(bool includeRepositoryMetadata) | ||
{ | ||
PackageURL purl = new("pkg:pypi/[email protected]"); | ||
var metadata = await _projectManager.GetPackageMetadataAsync(purl, includeRepositoryMetadata: includeRepositoryMetadata); | ||
|
||
if (includeRepositoryMetadata) | ||
{ | ||
Assert.IsNotNull(metadata.Repository); | ||
} | ||
else | ||
{ | ||
Assert.IsNull(metadata.Repository); | ||
} | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("pkg:pypi/[email protected]", true)] | ||
[DataRow("pkg:pypi/[email protected]", false)] | ||
|