File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 44package gitcmd
55
66import (
7+ "fmt"
8+ "os"
79 "testing"
810
11+ "code.gitea.io/gitea/modules/setting"
12+ "code.gitea.io/gitea/modules/tempdir"
13+
914 "github.com/stretchr/testify/assert"
1015)
1116
17+ func TestMain (m * testing.M ) {
18+ gitHomePath , cleanup , err := tempdir .OsTempDir ("gitea-test" ).MkdirTempRandom ("git-home" )
19+ if err != nil {
20+ _ , _ = fmt .Fprintf (os .Stderr , "unable to create temp dir: %v" , err )
21+ os .Exit (1 )
22+ }
23+ defer cleanup ()
24+
25+ setting .Git .HomePath = gitHomePath
26+ }
27+
1228func TestRunWithContextStd (t * testing.T ) {
1329 cmd := NewCommand ("--version" )
1430 stdout , stderr , err := cmd .RunStdString (t .Context (), & RunOpts {})
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ func HomeDir() string {
3232 if setting .Git .HomePath == "" {
3333 // strict check, make sure the git module is initialized correctly.
3434 // attention: when the git module is called in gitea sub-command (serv/hook), the log module might not obviously show messages to users/developers.
35- // for example: if there is gitea git hook code calling cmd. NewCommand before git.InitXxx, the integration test won't show the real failure reasons.
35+ // for example: if there is gitea git hook code calling NewCommand before git.InitXxx, the integration test won't show the real failure reasons.
3636 log .Fatal ("Unable to init Git's HomeDir, incorrect initialization of the setting and git modules" )
3737 return ""
3838 }
You can’t perform that action at this time.
0 commit comments