Skip to content

Commit ac6ed7f

Browse files
committed
Add the missing directories to the testrepos
1 parent 4231ccc commit ac6ed7f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

models/unittest/testdb.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,26 @@ func MainTest(m *testing.M, pathToGiteaRoot string, fixtureFiles ...string) {
104104
fatalTestError("util.CopyDir: %v\n", err)
105105
}
106106

107+
ownerDirs, err := os.ReadDir(pathToGiteaRoot)
108+
if err != nil {
109+
fatalTestError("unable to read the new repo root: %v\n", err)
110+
}
111+
for _, ownerDir := range ownerDirs {
112+
if !ownerDir.Type().IsDir() {
113+
continue
114+
}
115+
repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
116+
if err != nil {
117+
fatalTestError("unable to read the new repo root: %v\n", err)
118+
}
119+
for _, repoDir := range repoDirs {
120+
_ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
121+
_ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
122+
_ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
123+
_ = os.MkdirAll(filepath.Join(pathToGiteaRoot, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
124+
}
125+
}
126+
107127
exitStatus := m.Run()
108128
if err = util.RemoveAll(repoRootPath); err != nil {
109129
fatalTestError("util.RemoveAll: %v\n", err)
@@ -152,5 +172,22 @@ func PrepareTestEnv(t testing.TB) {
152172
assert.NoError(t, util.RemoveAll(setting.RepoRootPath))
153173
metaPath := filepath.Join(giteaRoot, "integrations", "gitea-repositories-meta")
154174
assert.NoError(t, util.CopyDir(metaPath, setting.RepoRootPath))
175+
176+
ownerDirs, err := os.ReadDir(setting.RepoRootPath)
177+
assert.NoError(t, err)
178+
for _, ownerDir := range ownerDirs {
179+
if !ownerDir.Type().IsDir() {
180+
continue
181+
}
182+
repoDirs, err := os.ReadDir(filepath.Join(setting.RepoRootPath, ownerDir.Name()))
183+
assert.NoError(t, err)
184+
for _, repoDir := range repoDirs {
185+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "pack"), 0755)
186+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "objects", "info"), 0755)
187+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "heads"), 0755)
188+
_ = os.MkdirAll(filepath.Join(setting.RepoRootPath, ownerDir.Name(), repoDir.Name(), "refs", "tag"), 0755)
189+
}
190+
}
191+
155192
base.SetupGiteaRoot() // Makes sure GITEA_ROOT is set
156193
}

0 commit comments

Comments
 (0)