-
-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added feature to NugetMetaAnalyzer to exclude pre-release versions.
- Loading branch information
1 parent
b60040f
commit 8511bf2
Showing
2 changed files
with
62 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,47 @@ public void testAnalyzer() throws Exception { | |
Assert.assertNotNull(metaModel.getPublishedTimestamp()); | ||
} | ||
|
||
|
||
// This test is to check if the analyzer is excluding pre-release versions | ||
// The test is transitent depending on the current version of the package | ||
// retrieved from the repository at the time of running. | ||
// When it was created, the latest release version was 9.0.0-preview.1.24080.9 | ||
//@Test | ||
public void testAnalyzerExcludingPreRelease() throws Exception { | ||
Component component = new Component(); | ||
component.setPurl(new PackageURL("pkg:nuget/[email protected]")); | ||
NugetMetaAnalyzer analyzer = new NugetMetaAnalyzer(); | ||
|
||
analyzer.setRepositoryBaseUrl("https://api.nuget.org"); | ||
MetaModel metaModel = analyzer.analyze(component); | ||
|
||
Assert.assertTrue(analyzer.isApplicable(component)); | ||
Assert.assertEquals(RepositoryType.NUGET, analyzer.supportedRepositoryType()); | ||
Assert.assertNotNull(metaModel.getLatestVersion()); | ||
|
||
Assert.assertFalse(metaModel.getLatestVersion().contains("-")); | ||
} | ||
|
||
// This test is to check if the analyzer is including pre-release versions | ||
// The test is transitent depending on the current version of the package | ||
// retrieved from the repository at the time of running. | ||
// When it was created, the latest release version was 9.0.0-preview.1.24080.9 | ||
//@Test | ||
public void testAnalyzerIncludingPreRelease() throws Exception { | ||
Component component = new Component(); | ||
component.setPurl(new PackageURL("pkg:nuget/[email protected]")); | ||
NugetMetaAnalyzer analyzer = new NugetMetaAnalyzer(); | ||
|
||
analyzer.setRepositoryBaseUrl("https://api.nuget.org"); | ||
MetaModel metaModel = analyzer.analyze(component); | ||
|
||
Assert.assertTrue(analyzer.isApplicable(component)); | ||
Assert.assertEquals(RepositoryType.NUGET, analyzer.supportedRepositoryType()); | ||
Assert.assertNotNull(metaModel.getLatestVersion()); | ||
|
||
Assert.assertTrue(metaModel.getLatestVersion().contains("-")); | ||
} | ||
|
||
@Test | ||
public void testAnalyzerWithPrivatePackageRepository() throws Exception { | ||
String mockIndexResponse = readResourceFileToString("/unit/tasks/repositories/https---localhost-1080-v3-index.json"); | ||
|