88 "context"
99 "fmt"
1010 "os"
11- "path"
1211 "path/filepath"
1312 "runtime"
1413 "testing"
@@ -35,27 +34,7 @@ func PrepareTestEnv(t *testing.T, skip int, syncModels ...any) (*xorm.Engine, fu
3534 ourSkip := 2
3635 ourSkip += skip
3736 deferFn := testlogger .PrintCurrentTest (t , ourSkip )
38- assert .NoError (t , os .RemoveAll (setting .RepoRootPath ))
39- assert .NoError (t , unittest .CopyDir (path .Join (filepath .Dir (setting .AppPath ), "tests/gitea-repositories-meta" ), setting .RepoRootPath ))
40- ownerDirs , err := os .ReadDir (setting .RepoRootPath )
41- if err != nil {
42- assert .NoError (t , err , "unable to read the new repo root: %v\n " , err )
43- }
44- for _ , ownerDir := range ownerDirs {
45- if ! ownerDir .Type ().IsDir () {
46- continue
47- }
48- repoDirs , err := os .ReadDir (filepath .Join (setting .RepoRootPath , ownerDir .Name ()))
49- if err != nil {
50- assert .NoError (t , err , "unable to read the new repo root: %v\n " , err )
51- }
52- for _ , repoDir := range repoDirs {
53- _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "objects" , "pack" ), 0o755 )
54- _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "objects" , "info" ), 0o755 )
55- _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "refs" , "heads" ), 0o755 )
56- _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "refs" , "tag" ), 0o755 )
57- }
58- }
37+ assert .NoError (t , unittest .SyncDirs (filepath .Join (filepath .Dir (setting .AppPath ), "tests/gitea-repositories-meta" ), setting .RepoRootPath ))
5938
6039 if err := deleteDB (); err != nil {
6140 t .Errorf ("unable to reset database: %v" , err )
@@ -123,20 +102,20 @@ func MainTest(m *testing.M) {
123102 if runtime .GOOS == "windows" {
124103 giteaBinary += ".exe"
125104 }
126- setting .AppPath = path .Join (giteaRoot , giteaBinary )
105+ setting .AppPath = filepath .Join (giteaRoot , giteaBinary )
127106 if _ , err := os .Stat (setting .AppPath ); err != nil {
128107 fmt .Printf ("Could not find gitea binary at %s\n " , setting .AppPath )
129108 os .Exit (1 )
130109 }
131110
132111 giteaConf := os .Getenv ("GITEA_CONF" )
133112 if giteaConf == "" {
134- giteaConf = path .Join (filepath .Dir (setting .AppPath ), "tests/sqlite.ini" )
113+ giteaConf = filepath .Join (filepath .Dir (setting .AppPath ), "tests/sqlite.ini" )
135114 fmt .Printf ("Environment variable $GITEA_CONF not set - defaulting to %s\n " , giteaConf )
136115 }
137116
138- if ! path .IsAbs (giteaConf ) {
139- setting .CustomConf = path .Join (giteaRoot , giteaConf )
117+ if ! filepath .IsAbs (giteaConf ) {
118+ setting .CustomConf = filepath .Join (giteaRoot , giteaConf )
140119 } else {
141120 setting .CustomConf = giteaConf
142121 }
0 commit comments