Skip to content

Commit

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

}

func TestIsGitBranch(t *testing.T) {
testCases := []struct {
branchName string
expected bool
explanation string
}{
{
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 c11821b

Please sign in to comment.