-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Konrad Jamrozik
committed
Jan 11, 2023
1 parent
cdcd619
commit 3758b5a
Showing
14 changed files
with
315 additions
and
287 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
58 changes: 0 additions & 58 deletions
58
tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/MainTests.cs
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
tools/code-owners-parser/Azure.Sdk.Tools.RetrieveCodeOwners.Tests/ProgramTests.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,58 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using Azure.Sdk.Tools.CodeOwnersParser; | ||
using NUnit.Framework; | ||
|
||
namespace Azure.Sdk.Tools.RetrieveCodeOwners.Tests | ||
{ | ||
/// <summary> | ||
/// Test class for Azure.Sdk.Tools.RetrieveCodeOwners.Program. | ||
/// </summary> | ||
[TestFixture] | ||
public class ProgramTests | ||
{ | ||
private const string CodeownersFilePath = "CODEOWNERS"; | ||
|
||
private static readonly object[] sourceLists = | ||
{ | ||
new object[] {"sdk", false, new List<string> { "person1", "person2" } }, | ||
new object[] { "/sdk", false, new List<string> { "person1", "person2" } }, | ||
new object[] { "sdk/noPath", false, new List<string> { "person1", "person2" } }, | ||
new object[] { "/sdk/azconfig", false, new List<string> { "person3", "person4" } }, | ||
new object[] { "/sdk/azconfig/package", false, new List<string> { "person3", "person4" } }, | ||
new object[] { "/sdk/testUser/", true, new List<string> { "azure-sdk" } }, | ||
new object[] { "/sd", true, new List<string>() } | ||
}; | ||
|
||
[TestCaseSource(nameof(sourceLists))] | ||
public void TestOnNormalOutput(string targetPath, bool excludeNonUserAliases, List<string> expectedOwners) | ||
{ | ||
using var consoleOutput = new ConsoleOutput(); | ||
|
||
// Act | ||
Program.Main(targetPath, CodeownersFilePath, excludeNonUserAliases); | ||
|
||
string actualOutput = consoleOutput.GetOutput(); | ||
AssertOwners(actualOutput, expectedOwners); | ||
} | ||
|
||
[TestCase("PathNotExist")] | ||
[TestCase("http://testLink")] | ||
[TestCase("https://testLink")] | ||
public void TestOnError(string codeownersPath) | ||
{ | ||
Assert.That(Program.Main("sdk", codeownersPath), Is.EqualTo(1)); | ||
} | ||
|
||
private static void AssertOwners(string actualOutput, List<string> expectedOwners) | ||
{ | ||
CodeownersEntry? actualEntry = JsonSerializer.Deserialize<CodeownersEntry>(actualOutput); | ||
List<string> actualOwners = actualEntry!.Owners; | ||
Assert.That(actualOwners, Has.Count.EqualTo(expectedOwners.Count)); | ||
for (int i = 0; i < actualOwners.Count; i++) | ||
{ | ||
Assert.That(actualOwners[i], Is.EqualTo(expectedOwners[i])); | ||
} | ||
} | ||
} | ||
} |
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
109 changes: 0 additions & 109 deletions
109
tools/code-owners-parser/CodeOwnersParser/CodeOwnersFile.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.