Skip to content

Commit

Permalink
ref: Update TestGetGitBranch test
Browse files Browse the repository at this point in the history
It makes more sense to validate this functionality using a proper
repository, rather than initializing an empty repository.
  • Loading branch information
Erick Kramer authored and ErickKramer committed Jul 2, 2024
1 parent 572c3aa commit c552406
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/git_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,16 @@ func TestGitStatus(t *testing.T) {
}

func TestGetGitBranch(t *testing.T) {
if utils.GetGitBranch("/tmp/testdata/valid_repo") != "main" {
testingBranch := "jazzy"
repoPath := "/tmp/testdata/demos_branch"
if utils.GitClone("https://github.com/ros2/demos.git", testingBranch, repoPath, true, false, false) != utils.SuccessfullClone {
t.Errorf("Expected to successfully clone git repository")
}
if utils.GetGitBranch(repoPath) != testingBranch {
t.Errorf("Failed to get main branch for valid git repository")
}
testingTag := "0.34.0"
repoPath := "/tmp/testdata/demos_branch"
if utils.GitClone("https://github.com/ros2/demos.git", testingTag, repoPath, false, false, false) != utils.SuccessfullClone {
if utils.GitClone("https://github.com/ros2/demos.git", testingTag, repoPath, true, false, false) != utils.SuccessfullClone {
t.Errorf("Expected to successfully clone git repository")
}
obtainedTag := utils.GetGitBranch(repoPath)
Expand Down

0 comments on commit c552406

Please sign in to comment.