@@ -11,10 +11,10 @@ import (
1111
1212func Test_rootCmd (t * testing.T ) {
1313 // Setup test repository
14- _ , cleanup := setupTestRepo (t , "https://github.com/zhaochunqi/git-open.git" , "main" )
14+ _ , cleanup := SetupTestRepo (t , "https://github.com/zhaochunqi/git-open.git" , "main" )
1515 defer cleanup ()
1616
17- // Save original openURLInBrowser function
17+ // Save original openURLInBrowser function and restore after test
1818 original := OpenURLInBrowser
1919 defer func () {
2020 OpenURLInBrowser = original
@@ -56,7 +56,7 @@ func Test_rootCmd(t *testing.T) {
5656 t .Errorf ("rootCmd.RunE() error = %v" , err )
5757 return
5858 }
59-
59+
6060 if got := buf .String (); got != tt .wantOutput {
6161 t .Errorf ("root command output = %q, want %q" , got , tt .wantOutput )
6262 }
@@ -118,16 +118,16 @@ func Test_Execute(t *testing.T) {
118118 // Setup logic moved directly into the test case
119119 switch tt .name {
120120 case "normal execution - github main branch" :
121- _ , cleanup := setupTestRepo (t , "https://github.com/zhaochunqi/git-open.git" , "main" )
121+ _ , cleanup := SetupTestRepo (t , "https://github.com/zhaochunqi/git-open.git" , "main" )
122122 t .Cleanup (cleanup )
123123 case "normal execution - github feature branch" :
124- _ , cleanup := setupTestRepo (t , "https://github.com/zhaochunqi/git-open.git" , "feature-branch" )
124+ _ , cleanup := SetupTestRepo (t , "https://github.com/zhaochunqi/git-open.git" , "feature-branch" )
125125 t .Cleanup (cleanup )
126126 case "normal execution - gitlab feature branch" :
127- _ , cleanup := setupTestRepo (t , "https://gitlab.com/zhaochunqi/git-open.git" , "feature-branch" )
127+ _ , cleanup := SetupTestRepo (t , "https://gitlab.com/zhaochunqi/git-open.git" , "feature-branch" )
128128 t .Cleanup (cleanup )
129129 case "normal execution - bitbucket feature branch" :
130- _ , cleanup := setupTestRepo (t , "https://bitbucket.org/zhaochunqi/git-open.git" , "feature-branch" )
130+ _ , cleanup := SetupTestRepo (t , "https://bitbucket.org/zhaochunqi/git-open.git" , "feature-branch" )
131131 t .Cleanup (cleanup )
132132 case "no git repo" :
133133 // Create and change to temp dir without git repo
0 commit comments