-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug where pipreport used index-urls from requirements.txt (#1227)
* fix bug where pipreport used index urls in requirements.txt * update tests * docs * add --no-input to pip install, so we do not hang waiting for user input * pr feedback: performance and cleanup * bump version
- Loading branch information
1 parent
f27fe8e
commit edf0c8d
Showing
11 changed files
with
300 additions
and
61 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
55 changes: 55 additions & 0 deletions
55
test/Microsoft.ComponentDetection.Common.Tests/FileUtilityServiceTests.cs
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
namespace Microsoft.ComponentDetection.Common.Tests; | ||
|
||
using System.IO; | ||
using FluentAssertions; | ||
using Microsoft.ComponentDetection.Contracts; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
[TestCategory("Governance/All")] | ||
[TestCategory("Governance/ComponentDetection")] | ||
public class FileUtilityServiceTests | ||
{ | ||
private readonly IFileUtilityService fileUtilityService; | ||
|
||
public FileUtilityServiceTests() => | ||
this.fileUtilityService = new FileUtilityService(); | ||
|
||
[TestMethod] | ||
public void DuplicateFileWithoutLines_WithLinesToRemove_ShouldCreateDuplicateFileWithoutLines() | ||
{ | ||
// Get directory of current executing assembly | ||
var directory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); | ||
|
||
// Arrange | ||
var fileName = $"{directory}/Resources/test-file-duplicate.txt"; | ||
var removalIndicator = "//REMOVE"; | ||
var expectedDuplicateFilePath = Path.Combine(directory, "Resources", "temp.test-file-duplicate.txt"); | ||
|
||
// Act | ||
var (duplicateFilePath, createdDuplicate) = this.fileUtilityService.DuplicateFileWithoutLines(fileName, removalIndicator); | ||
|
||
// Assert | ||
createdDuplicate.Should().BeTrue(); | ||
duplicateFilePath.Should().Be(expectedDuplicateFilePath); | ||
File.Exists(expectedDuplicateFilePath).Should().BeTrue(); | ||
} | ||
|
||
[TestMethod] | ||
public void DuplicateFileWithoutLines_WithoutLinesToRemove_ShouldNotCreateDuplicateFile() | ||
{ | ||
// Get directory of current executing assembly | ||
var directory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); | ||
|
||
// Arrange | ||
var fileName = $"{directory}/Resources/test-file-duplicate.txt"; | ||
var removalIndicator = "//NOTEXIST"; | ||
|
||
// Act | ||
var (duplicateFilePath, createdDuplicate) = this.fileUtilityService.DuplicateFileWithoutLines(fileName, removalIndicator); | ||
|
||
// Assert | ||
createdDuplicate.Should().BeFalse(); | ||
duplicateFilePath.Should().BeNull(); | ||
} | ||
} |
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
3 changes: 3 additions & 0 deletions
3
test/Microsoft.ComponentDetection.Common.Tests/Resources/test-file-duplicate.txt
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
hello | ||
//REMOVE | ||
world |
Oops, something went wrong.