Skip to content
Snippets Groups Projects
Commit 1d2ab9fe authored by Stanley Goldman's avatar Stanley Goldman
Browse files

Correcting unit tests

parent a5aae897
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ namespace GitHub.Unity.Helpers
{
public static class RegularExpressions
{
public static readonly Regex BranchNameRegex = new Regex(@"^(?<name>[\w\d\/\-_]+)$");
public static readonly Regex BranchNameRegex = new Regex(@"^(?<name>[\.\w\d\/\-_]+)$");
}
public static class BranchNameValidator
......@@ -12,8 +12,14 @@ namespace GitHub.Unity.Helpers
public static bool IsBranchNameValid(string branchName)
{
return !string.IsNullOrEmpty(branchName)
&& !branchName.Equals(".")
&& !branchName.StartsWith("/")
&& !branchName.EndsWith("/")
&& !branchName.EndsWith(".")
&& !branchName.Contains("//")
&& !branchName.Contains(@"\")
&& !branchName.EndsWith(".lock")
&& !(branchName.StartsWith(".") && branchName.Contains("/"))
&& RegularExpressions.BranchNameRegex.IsMatch(branchName);
}
}
......
......@@ -28,7 +28,7 @@ namespace UnitTests
[TestCase(false, "@", TestName = "Single character cannot be @")]
[TestCase(false, ".", TestName = "Single character cannot be [period]")]
[TestCase(true, "features/feature-1", TestName = "Folder and branch name is valid")]
[TestCase(true, "features\\feature-1", TestName = "Backslash is not a valid character")]
[TestCase(false, @"features\feature-1", TestName = "Backslash is not a valid character")]
[TestCase(true, ".hidden", TestName = "Branch name is valid when starting with [period]")]
[TestCase(false, ".features/feature-1", TestName = "Folder and branch name is not valid when starting with [period]")]
[TestCase(false, "features//feature-1", TestName = "Multiple consecutive slashes are not valid")]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment