Skip to content

Commit 97fc21b

Browse files
committed
Fix test
1 parent acfa35a commit 97fc21b

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

modules/git/repo_base_nogogit.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ func (repo *Repository) CatFileBatch(ctx context.Context) (*BatchCatFile, func()
7474
}, nil
7575
}
7676

77-
setting.PanicInDevOrTesting("Opening temporary cat file batch for: %s", repo.Path)
77+
if !setting.DisableTempCatFileBatchCheck {
78+
setting.PanicInDevOrTesting("Opening temporary cat file batch for: %s", repo.Path)
79+
}
7880
tempBatch, err := NewBatchCatFile(ctx, repo.Path, false)
7981
if err != nil {
8082
return nil, nil, err

modules/setting/git.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import (
1111
"code.gitea.io/gitea/modules/log"
1212
)
1313

14+
// DisableTempCatFileBatchCheck disables the temporary cat-file batch check
15+
var DisableTempCatFileBatchCheck = false
16+
1417
// Git settings
1518
var Git = struct {
1619
Path string

tests/integration/git_misc_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ import (
1818
user_model "code.gitea.io/gitea/models/user"
1919
"code.gitea.io/gitea/modules/git"
2020
"code.gitea.io/gitea/modules/gitrepo"
21+
"code.gitea.io/gitea/modules/setting"
22+
"code.gitea.io/gitea/modules/test"
2123
files_service "code.gitea.io/gitea/services/repository/files"
2224

2325
"github.com/stretchr/testify/assert"
2426
)
2527

2628
func TestDataAsyncDoubleRead_Issue29101(t *testing.T) {
29+
// in this test, we will have two parallel readers reading the same blob
30+
// So we need to ignore the temporary CatFileBranch checking to make the test pass
31+
defer test.MockVariableValue(&setting.DisableTempCatFileBatchCheck, true)
32+
2733
onGiteaRun(t, func(t *testing.T, u *url.URL) {
2834
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
2935
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})

0 commit comments

Comments
 (0)