Skip to content

Commit

Permalink
test: test isGitBranch function (#1040)
Browse files Browse the repository at this point in the history
Signed-off-by: Mehant Kammakomati <mehant.kammakomati2@ibm.com>
  • Loading branch information
kmehant authored Jun 1, 2023
1 parent 5113d4c commit 87d53a2
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions common/vcs/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,43 @@ func TestClone(t *testing.T) {
}

}

func TestIsGitBranch(t *testing.T) {
testCases := []struct {
branchName string
expected bool
}{
{
branchName: "main",
expected: true,
},
{
branchName: "123branchName",
expected: false,
},
{
branchName: "feature/branchName#1",
expected: false,
},
{
branchName: "feature/branchName_1",
expected: true,
},
{
branchName: "",
expected: false,
},
{
branchName: "$develop",
expected: false,
},
}

for _, testCase := range testCases {
isValidBranchName := isGitBranch(testCase.branchName)
if isValidBranchName != testCase.expected {
t.Errorf("failed branch %s isValid = %t, but got = %t\n", testCase.branchName, testCase.expected, isValidBranchName)
}
}

}

0 comments on commit 87d53a2

Please sign in to comment.