Skip to content

Commit

Permalink
dedup test battery + improve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Jamrozik committed Feb 19, 2023
1 parent b921df1 commit 2cacb46
Show file tree
Hide file tree
Showing 2 changed files with 209 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
namespace Azure.Sdk.Tools.CodeOwnersParser.Tests;

/// <summary>
/// Please see the comment on:
/// - Azure.Sdk.Tools.CodeOwnersParser.Tests.CodeownersFileTests.testCases
/// Please see the comment on CodeownersFileTests.testCases
/// </summary>
[TestFixture]
public class CodeownersFileTests
Expand All @@ -23,176 +22,175 @@ public class CodeownersFileTests
private static readonly TestCase[] testCases =
{
// @formatter:off
// Path: Expected match:
// Codeowners , Target , |
new( "/**" , "a" , true ),
new( "/**" , "A" , true ),
new( "/**" , "/a" , true ),
new( "/**" , "a/" , true ),
new( "/**" , "/a/" , true ),
new( "/**" , "/a/b" , true ),
new( "/**" , "/a/b/" , true ),
new( "/**" , "/a/b/c" , true ),
new( "/**" , "[" , true ),
new( "/**" , "]" , true ),
new( "/" , "a" , false ),
new( "/" , "A" , false ),
new( "/" , "/a" , false ),
new( "/" , "a/" , false ),
new( "/" , "/a/" , false ),
new( "/" , "/a/b" , false ),
new( "/a" , "a" , true ),
new( "/a" , "A" , false ),
new( "/a" , "/a" , true ),
new( "/a" , "a/" , false ),
new( "/a" , "/a/" , false ),
new( "/a" , "/a/b" , false ),
new( "/a" , "/a/b/" , false ),
new( "/a" , "/a\\ b" , false ),
new( "/a" , "/x/a/b" , false ),
new( "a" , "a" , false ),
new( "a" , "ab" , false ),
new( "a" , "ab/" , false ),
new( "a" , "/ab/" , false ),
new( "a" , "A" , false ),
new( "a" , "/a" , false ),
new( "a" , "a/" , false ),
new( "a" , "/a/" , false ),
new( "a" , "/a/b" , false ),
new( "a" , "/a/b/" , false ),
new( "a" , "/x/a/b" , false ),
new( "/a/" , "a" , false ),
new( "/a/" , "/a" , false ),
new( "/a/" , "a/" , true ),
new( "/a/" , "/a/" , true ),
new( "/a/" , "/a/b" , true ),
new( "/a/" , "/a\\ b" , false ),
new( "/a/" , "/a\\ b/" , false ),
new( "/a/" , "/a/a\\ b/" , true ),
new( "/a/" , "/a/b/" , true ),
new( "/a/" , "/A/b/" , false ),
new( "/a/" , "/x/a/b" , false ),
new( "/a/b/" , "/a" , false ),
new( "/a/b/" , "/a/" , false ),
new( "/a/b/" , "/a/b" , false ),
new( "/a/b/" , "/a/b/" , true ),
new( "/a/b/" , "/a/b/c" , true ),
new( "/a/b/" , "/a/b/c/" , true ),
new( "/a/b/" , "/a/b/c/d" , true ),
new( "/a/b" , "/a" , false ),
new( "/a/b" , "/a/" , false ),
new( "/a/b" , "/a/b" , true ),
new( "/a/b" , "/a/b/" , false ),
new( "/a/b" , "/a/bc" , false ),
new( "/a/b" , "/a/bc/" , false ),
new( "/a/b" , "/a/b/c" , false ),
new( "/a/b" , "/a/b/c/" , false ),
new( "/a/b" , "/a/b/c/d" , false ),
new( "/!a" , "!a" , false ),
new( "/!a" , "b" , false ),
new( "/a[b" , "a[b" , false ),
new( "/a]b" , "a]b" , false ),
new( "/a?b" , "a?b" , false ),
new( "/a?b" , "axb" , false ),
new( "/a" , "*" , false ),
new( "/*" , "*" , false ),
new( "/*" , "a" , true ),
new( "/*" , "a/" , false ),
new( "/*" , "/a" , true ),
new( "/*" , "/a/" , false ),
new( "/*" , "a/b" , false ),
new( "/*" , "/a/b" , false ),
new( "/*" , "[" , true ),
new( "/*" , "]" , true ),
new( "/*" , "!" , true ),
new( "/**" , "!" , true ),
new( "/a*" , "a" , true ),
new( "/a*" , "a/x" , true ),
new( "/a*" , "a/x/d" , true ),
new( "/a*" , "ab" , true ),
new( "/a*" , "ab/x" , true ),
new( "/a*" , "ab/x/d" , true ),
new( "/a/**" , "a" , false ),
new( "/*/**" , "a" , false ),
new( "/*/**" , "a/" , false ),
new( "/*/**" , "a/b" , false ),
new( "/*/" , "a" , false ),
new( "/*/" , "a/" , true ),
new( "/*/b" , "a/b" , true ),
new( "/**/a" , "a" , true ),
new( "/**/a" , "x/ba" , false ),
new( "/a/*" , "a" , false ),
new( "/a/*" , "a/" , true ),
new( "/a/*" , "a/b" , true ),
new( "/a/*" , "a/b/" , false ),
new( "/a/*" , "a/b/c" , false ),
new( "/a/*/" , "a" , false ),
new( "/a/*/" , "a/" , false ),
new( "/a/*/" , "a/b" , false ),
new( "/a/*/" , "a/b/" , true ),
new( "/a/*/" , "a/b/c" , true ),
new( "/a/**" , "a" , false ),
new( "/a/**" , "a/" , false ),
new( "/a/**" , "a/b" , false ),
new( "/a/**" , "a/b/" , false ),
new( "/a/**" , "a/b/c" , false ),
new( "/a/**/" , "a" , false ),
new( "/a/**/" , "a/" , false ),
new( "/a/**/" , "a/b" , false ),
new( "/a/**/" , "a/b/" , false ),
new( "/a/**/" , "a/b/c" , false ),
new( "/**/a/" , "a" , false ),
new( "/**/a/" , "a/" , true ),
new( "/**/a/" , "a/b" , true ),
new( "/**/b/" , "a/b" , false ),
new( "/**/b/" , "a/b/" , true ),
new( "/**/b/" , "a/c/" , false ),
new( "/a/*/b/" , "a/b/" , false ),
new( "/a/*/b/" , "a/x/b/" , true ),
new( "/a/*/b/" , "a/x/b/c" , true ),
new( "/a/*/b/" , "a/x/c" , false ),
new( "/a/*/b/" , "a/x/y/b" , false ),
new( "/a**b/" , "a/x/y/b" , false ),
new( "/a/**/b/" , "a/b" , false ),
new( "/a/**/b/" , "a/b/" , true ),
new( "/a/**/b/" , "a/x/b/" , true ),
new( "/a/**/b/" , "a/x/y/b/" , true ),
new( "/a/**/b/" , "a/x/y/c" , false ),
new( "/a/**/b/" , "a-b/" , false ),
new( "a/*/*" , "a/b" , false ),
new( "/a/*/*/d" , "a/b/c/d" , true ),
new( "/a/*/*/d" , "a/b/x/c/d" , false ),
new( "/a/**/*/d" , "a/b/x/c/d" , true ),
new( "*/*/b" , "a/b" , false ),
new( "/a*/" , "abc/" , true ),
new( "/a*/" , "ab/c/" , true ),
new( "/*b*/" , "axbyc/" , true ),
new( "/*c/" , "abc/" , true ),
new( "/*c/" , "a/abc/" , false ),
new( "/a*c/" , "axbyc/" , true ),
new( "/a*c/" , "axb/yc/" , false ),
new( "/**/*x*/" , "a/b/cxy/d" , true ),
new( "/a/*.md" , "a/x.md" , true ),
new( "/*/*/*.md" , "a/b/x.md" , true ),
new( "/**/*.md" , "a/b.md/x.md" , true ),
new( "**/*.md" , "a/b.md/x.md" , false ),
new( "/*.md" , "a/md" , false ),
new( "/a.*" , "a.b" , true ),
new( "/a.*" , "a.b/" , true ),
new( "/a.*" , "x/a.b/" , false ),
new( "/a.*/" , "a.b" , false ),
new( "/a.*/" , "a.b/" , true ),
new( "/**/*x*/AB/*/CD" , "a/b/cxy/AB/fff/CD" , true ),
new( "/**/*x*/AB/*/CD" , "a/b/cxy/AB/ff/ff/CD" , false ),
new( "/**/*x*/AB/**/CD/*" , "a/b/cxy/AB/ff/ff/CD" , false ),
new( "/**/*x*/AB/**/CD/*" , "a/b/cxy/AB/ff/ff/CD/" , true ),
new( "/**/*x*/AB/**/CD/*" , "a/b/cxy/AB/[]/!!/CD/h" , true ),

// Path: Expected match:
// Codeowners , Target , |
new ( "/**" , "a" , true ),
new ( "/**" , "A" , true ),
new ( "/**" , "/a" , true ),
new ( "/**" , "a/" , true ),
new ( "/**" , "/a/" , true ),
new ( "/**" , "/a/b" , true ),
new ( "/**" , "/a/b/" , true ),
new ( "/**" , "/a/b/c" , true ),
new ( "/**" , "[" , true ),
new ( "/**" , "]" , true ),
new ( "/" , "a" , false ),
new ( "/" , "A" , false ),
new ( "/" , "/a" , false ),
new ( "/" , "a/" , false ),
new ( "/" , "/a/" , false ),
new ( "/" , "/a/b" , false ),
new ( "/a" , "a" , true ),
new ( "/a" , "A" , false ),
new ( "/a" , "/a" , true ),
new ( "/a" , "a/" , false ),
new ( "/a" , "/a/" , false ),
new ( "/a" , "/a/b" , false ),
new ( "/a" , "/a/b/" , false ),
new ( "/a" , "/a\\ b" , false ),
new ( "/a" , "/x/a/b" , false ),
new ( "a" , "a" , false ),
new ( "a" , "ab" , false ),
new ( "a" , "ab/" , false ),
new ( "a" , "/ab/" , false ),
new ( "a" , "A" , false ),
new ( "a" , "/a" , false ),
new ( "a" , "a/" , false ),
new ( "a" , "/a/" , false ),
new ( "a" , "/a/b" , false ),
new ( "a" , "/a/b/" , false ),
new ( "a" , "/x/a/b" , false ),
new ( "/a/" , "a" , false ),
new ( "/a/" , "/a" , false ),
new ( "/a/" , "a/" , true ),
new ( "/a/" , "/a/" , true ),
new ( "/a/" , "/a/b" , true ),
new ( "/a/" , "/a\\ b" , false ),
new ( "/a/" , "/a\\ b/" , false ),
new ( "/a/" , "/a/a\\ b/" , true ),
new ( "/a/" , "/a/b/" , true ),
new ( "/a/" , "/A/b/" , false ),
new ( "/a/" , "/x/a/b" , false ),
new ( "/a/b/" , "/a" , false ),
new ( "/a/b/" , "/a/" , false ),
new ( "/a/b/" , "/a/b" , false ),
new ( "/a/b/" , "/a/b/" , true ),
new ( "/a/b/" , "/a/b/c" , true ),
new ( "/a/b/" , "/a/b/c/" , true ),
new ( "/a/b/" , "/a/b/c/d" , true ),
new ( "/a/b" , "/a" , false ),
new ( "/a/b" , "/a/" , false ),
new ( "/a/b" , "/a/b" , true ),
new ( "/a/b" , "/a/b/" , false ),
new ( "/a/b" , "/a/bc" , false ),
new ( "/a/b" , "/a/bc/" , false ),
new ( "/a/b" , "/a/b/c" , false ),
new ( "/a/b" , "/a/b/c/" , false ),
new ( "/a/b" , "/a/b/c/d" , false ),
new ( "/!a" , "!a" , false ),
new ( "/!a" , "b" , false ),
new ( "/a[b" , "a[b" , false ),
new ( "/a]b" , "a]b" , false ),
new ( "/a?b" , "a?b" , false ),
new ( "/a?b" , "axb" , false ),
new ( "/a" , "*" , false ),
new ( "/*" , "*" , false ),
new ( "/*" , "a" , true ),
new ( "/*" , "a/" , false ),
new ( "/*" , "/a" , true ),
new ( "/*" , "/a/" , false ),
new ( "/*" , "a/b" , false ),
new ( "/*" , "/a/b" , false ),
new ( "/*" , "[" , true ),
new ( "/*" , "]" , true ),
new ( "/*" , "!" , true ),
new ( "/**" , "!" , true ),
new ( "/a*" , "a" , true ),
new ( "/a*" , "a/x" , true ),
new ( "/a*" , "a/x/d" , true ),
new ( "/a*" , "ab" , true ),
new ( "/a*" , "ab/x" , true ),
new ( "/a*" , "ab/x/d" , true ),
new ( "/a/**" , "a" , false ),
new ( "/*/**" , "a" , false ),
new ( "/*/**" , "a/" , false ),
new ( "/*/**" , "a/b" , false ),
new ( "/*/" , "a" , false ),
new ( "/*/" , "a/" , true ),
new ( "/*/b" , "a/b" , true ),
new ( "/**/a" , "a" , true ),
new ( "/**/a" , "x/ba" , false ),
new ( "/a/*" , "a" , false ),
new ( "/a/*" , "a/" , true ),
new ( "/a/*" , "a/b" , true ),
new ( "/a/*" , "a/b/" , false ),
new ( "/a/*" , "a/b/c" , false ),
new ( "/a/*/" , "a" , false ),
new ( "/a/*/" , "a/" , false ),
new ( "/a/*/" , "a/b" , false ),
new ( "/a/*/" , "a/b/" , true ),
new ( "/a/*/" , "a/b/c" , true ),
new ( "/a/**" , "a" , false ),
new ( "/a/**" , "a/" , false ),
new ( "/a/**" , "a/b" , false ),
new ( "/a/**" , "a/b/" , false ),
new ( "/a/**" , "a/b/c" , false ),
new ( "/a/**/" , "a" , false ),
new ( "/a/**/" , "a/" , false ),
new ( "/a/**/" , "a/b" , false ),
new ( "/a/**/" , "a/b/" , false ),
new ( "/a/**/" , "a/b/c" , false ),
new ( "/**/a/" , "a" , false ),
new ( "/**/a/" , "a/" , true ),
new ( "/**/a/" , "a/b" , true ),
new ( "/**/b/" , "a/b" , false ),
new ( "/**/b/" , "a/b/" , true ),
new ( "/**/b/" , "a/c/" , false ),
new ( "/a/*/b/" , "a/b/" , false ),
new ( "/a/*/b/" , "a/x/b/" , true ),
new ( "/a/*/b/" , "a/x/b/c" , true ),
new ( "/a/*/b/" , "a/x/c" , false ),
new ( "/a/*/b/" , "a/x/y/b" , false ),
new ( "/a**b/" , "a/x/y/b" , false ),
new ( "/a/**/b/" , "a/b" , false ),
new ( "/a/**/b/" , "a/b/" , true ),
new ( "/a/**/b/" , "a/x/b/" , true ),
new ( "/a/**/b/" , "a/x/y/b/" , true ),
new ( "/a/**/b/" , "a/x/y/c" , false ),
new ( "/a/**/b/" , "a-b/" , false ),
new ( "a/*/*" , "a/b" , false ),
new ( "/a/*/*/d" , "a/b/c/d" , true ),
new ( "/a/*/*/d" , "a/b/x/c/d" , false ),
new ( "/a/**/*/d" , "a/b/x/c/d" , true ),
new ( "*/*/b" , "a/b" , false ),
new ( "/a*/" , "abc/" , true ),
new ( "/a*/" , "ab/c/" , true ),
new ( "/*b*/" , "axbyc/" , true ),
new ( "/*c/" , "abc/" , true ),
new ( "/*c/" , "a/abc/" , false ),
new ( "/a*c/" , "axbyc/" , true ),
new ( "/a*c/" , "axb/yc/" , false ),
new ( "/**/*x*/" , "a/b/cxy/d" , true ),
new ( "/a/*.md" , "a/x.md" , true ),
new ( "/*/*/*.md" , "a/b/x.md" , true ),
new ( "/**/*.md" , "a/b.md/x.md" , true ),
new ( "**/*.md" , "a/b.md/x.md" , false ),
new ( "/*.md" , "a/md" , false ),
new ( "/a.*" , "a.b" , true ),
new ( "/a.*" , "a.b/" , true ),
new ( "/a.*" , "x/a.b/" , false ),
new ( "/a.*/" , "a.b" , false ),
new ( "/a.*/" , "a.b/" , true ),
new ( "/**/*x*/AB/*/CD" , "a/b/cxy/AB/fff/CD" , true ),
new ( "/**/*x*/AB/*/CD" , "a/b/cxy/AB/ff/ff/CD" , false ),
new ( "/**/*x*/AB/**/CD/*" , "a/b/cxy/AB/ff/ff/CD" , false ),
new ( "/**/*x*/AB/**/CD/*" , "a/b/cxy/AB/ff/ff/CD/" , true ),
new ( "/**/*x*/AB/**/CD/*" , "a/b/cxy/AB/[]/!!/CD/h" , true ),
// @formatter:on
};

/// <summary>
/// Exercises Azure.Sdk.Tools.CodeOwnersParser.Tests.CodeownersFileTests.testCases.
/// Exercises CodeownersFileTests.testCases
/// See comment on that member for details.
/// </summary>
[TestCaseSource(nameof(testCases))]
Expand All @@ -217,6 +215,9 @@ private static void VerifyGetMatchingCodeownersEntry(
Assert.That(entry.Owners, Has.Count.EqualTo(expectedMatch ? 1 : 0));
}

/// <summary>
/// Please see comment on CodeownersFileTests.testCases
/// </summary>
public record TestCase(
string CodeownersPath,
string TargetPath,
Expand Down
Loading

0 comments on commit 2cacb46

Please sign in to comment.