forked from microsoft/OSSGadget
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix broken tests, add NPM scoped test. (microsoft#168)
- Loading branch information
Showing
4 changed files
with
19 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 | ||
FROM mcr.microsoft.com/dotnet/sdk:5.0 | ||
COPY . /app/ | ||
WORKDIR /app/src | ||
|
||
|
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 |
---|---|---|
|
@@ -111,6 +111,13 @@ public async Task NPM_Download_Version_Succeeds(string purl, string targetFilena | |
await TestDownload(purl, targetFilename, expectedDirectoryCount); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("pkg:npm/%40angular%[email protected]", "package.json", 1)] | ||
public async Task NPM_Download_ScopedVersion_Succeeds(string purl, string targetFilename, int expectedDirectoryCount) | ||
{ | ||
await TestDownload(purl, targetFilename, expectedDirectoryCount); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("pkg:nuget/[email protected]", "RandomType.nuspec", 1)] | ||
[DataRow("pkg:nuget/d3.TypeScript.DefinitelyTyped", "d3.TypeScript.DefinitelyTyped.nuspec", 1)] | ||
|
@@ -154,7 +161,7 @@ await Assert.ThrowsExceptionAsync<InternalTestFailureException>(async () => | |
} | ||
|
||
[DataTestMethod] | ||
[DataRow("pkg:vsm/ms-vscode/Theme-1337", "extension.vsixmanifest", 1)] | ||
[DataRow("pkg:vsm/ms-vscode/PowerShell", "extension.vsixmanifest", 1)] | ||
public async Task VSM_Download_Version_Succeeds(string purl, string targetFilename, int expectedDirectoryCount) | ||
{ | ||
await TestDownload(purl, targetFilename, expectedDirectoryCount); | ||
|
@@ -192,7 +199,7 @@ private void deleteTempDirs(PackageDownloader? packageDownloader, string tempDir | |
/// <param name="packageUrl"> </param> | ||
/// <param name="tempDirectoryName"> </param> | ||
/// <returns> </returns> | ||
private async Task<PackageDownloader?> DownloadPackage(PackageURL packageUrl, string tempDirectoryName, bool doCache = false) | ||
private PackageDownloader? DownloadPackage(PackageURL packageUrl, string tempDirectoryName, bool doCache = false) | ||
{ | ||
int numAttempts = 3; | ||
int numSecondsWait = 10; | ||
|
@@ -231,7 +238,7 @@ private async Task TestDownload(string purl, string targetFilename, int expected | |
try | ||
{ | ||
var packageUrl = new PackageURL(purl); | ||
var packageDownloader = DownloadPackage(packageUrl, tempDirectoryName).Result; | ||
var packageDownloader = DownloadPackage(packageUrl, tempDirectoryName); | ||
|
||
var targetFileWasDownloaded = Directory.EnumerateFiles(tempDirectoryName, targetFilename, SearchOption.AllDirectories).Any(); | ||
if (!targetFileWasDownloaded) | ||
|
@@ -242,18 +249,16 @@ private async Task TestDownload(string purl, string targetFilename, int expected | |
var topLevelDirectoryCount = Directory.GetDirectories(tempDirectoryName).Length; | ||
if (expectedDirectoryCount != topLevelDirectoryCount) | ||
{ | ||
Console.WriteLine(string.Join(";", Directory.GetDirectories(tempDirectoryName))); | ||
errorString = string.Format("Directory count {0} does not match expected {1}", topLevelDirectoryCount, expectedDirectoryCount); | ||
} | ||
|
||
// Download again (with caching) - TODO, move this to a separate test. | ||
await DownloadPackage(packageUrl, tempDirectoryName, true); | ||
packageDownloader = DownloadPackage(packageUrl, tempDirectoryName, true); | ||
|
||
// Re-calculate the top level directories, since in might have changed (it shouldn't). | ||
topLevelDirectoryCount = Directory.GetDirectories(tempDirectoryName).Length; | ||
if (expectedDirectoryCount != topLevelDirectoryCount) | ||
{ | ||
Console.WriteLine(string.Join(";", Directory.GetDirectories(tempDirectoryName))); | ||
errorString = string.Format("Directory count {0} does not match expected {1}", topLevelDirectoryCount, expectedDirectoryCount); | ||
} | ||
|
||
|