Skip to content

Commit a9cf69c

Browse files
committed
do the attachment directories copy only for the related tests
1 parent 0ffcf83 commit a9cf69c

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

tests/integration/release_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ func TestViewTagsList(t *testing.T) {
243243
func TestDownloadReleaseAttachment(t *testing.T) {
244244
defer tests.PrepareTestEnv(t)()
245245

246+
tests.PrepareAttachmentsStorage(t)
247+
246248
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2})
247249

248250
url := repo.Link() + "/releases/download/v1.1/README.md"

tests/test_utils.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,20 @@ func InitTest(requireGitea bool) {
179179
routers.InitWebInstalled(graceful.GetManager().HammerContext())
180180
}
181181

182+
func PrepareAttachmentsStorage(t testing.TB) {
183+
// prepare attachments directory and files
184+
assert.NoError(t, storage.Clean(storage.Attachments))
185+
186+
s, err := storage.NewStorage(setting.LocalStorageType, &setting.Storage{
187+
Path: filepath.Join(filepath.Dir(setting.AppPath), "tests", "testdata", "data", "attachments"),
188+
})
189+
assert.NoError(t, err)
190+
assert.NoError(t, s.IterateObjects("", func(p string, obj storage.Object) error {
191+
_, err = storage.Copy(storage.Attachments, p, s, p)
192+
return err
193+
}))
194+
}
195+
182196
func PrepareTestEnv(t testing.TB, skip ...int) func() {
183197
t.Helper()
184198
ourSkip := 1
@@ -213,18 +227,6 @@ func PrepareTestEnv(t testing.TB, skip ...int) func() {
213227
}
214228
}
215229

216-
// prepare attachments directory and files
217-
assert.NoError(t, storage.Clean(storage.Attachments))
218-
219-
s, err := storage.NewStorage(setting.LocalStorageType, &setting.Storage{
220-
Path: filepath.Join(filepath.Dir(setting.AppPath), "tests", "testdata", "data", "attachments"),
221-
})
222-
assert.NoError(t, err)
223-
assert.NoError(t, s.IterateObjects("", func(p string, obj storage.Object) error {
224-
_, err = storage.Copy(storage.Attachments, p, s, p)
225-
return err
226-
}))
227-
228230
// load LFS object fixtures
229231
// (LFS storage can be on any of several backends, including remote servers, so we init it with the storage API)
230232
lfsFixtures, err := storage.NewStorage(setting.LocalStorageType, &setting.Storage{

0 commit comments

Comments
 (0)