mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-10 09:41:52 +02:00
ci: fix LFS test pollution and exclude integration packages from gogit pass
Two CI failures from sharding/splitting: 1. TestAPILFSNotStarted and TestAPILFSLocksNotStarted set setting.LFS.StartServer = false but never restore it. In the pre-sharding sequential run a later test happened to set it back to true, but with sharding TestLFSRender and TestChangeRepoFilesForUpdateWithFileRename can land in a different shard and run with LFS disabled. Use test.MockVariableValue so the change is scoped to the test that makes it. 2. find-gogit-test-pkgs.sh enumerated every package whose tests import the gogit modules, including tests/integration, tests/integration/migration-test, and models/migrations/... These need a real DB / dedicated harness and have to be tested separately; mirror GO_TEST_PACKAGES' filter to exclude them. Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
This commit is contained in:
parent
9b6cd19493
commit
b266c64d24
@ -15,6 +15,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/lfs"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -22,7 +23,7 @@ import (
|
||||
|
||||
func TestAPILFSLocksNotStarted(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
setting.LFS.StartServer = false
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, false)()
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
|
||||
@ -38,7 +39,7 @@ func TestAPILFSLocksNotStarted(t *testing.T) {
|
||||
|
||||
func TestAPILFSLocksNotLogin(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
|
||||
@ -51,7 +52,7 @@ func TestAPILFSLocksNotLogin(t *testing.T) {
|
||||
|
||||
func TestAPILFSLocksLogged(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) // in org 3
|
||||
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4}) // in org 3
|
||||
|
||||
|
||||
@ -28,8 +28,7 @@ import (
|
||||
|
||||
func TestAPILFSNotStarted(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = false
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, false)()
|
||||
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
@ -48,8 +47,7 @@ func TestAPILFSNotStarted(t *testing.T) {
|
||||
|
||||
func TestAPILFSMediaType(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
@ -72,8 +70,7 @@ func createLFSTestRepository(t *testing.T, repoName string) *repo_model.Reposito
|
||||
|
||||
func TestAPILFSBatch(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
|
||||
repo := createLFSTestRepository(t, "lfs-batch-repo")
|
||||
|
||||
@ -326,8 +323,7 @@ func TestAPILFSBatch(t *testing.T) {
|
||||
|
||||
func TestAPILFSUpload(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
|
||||
repo := createLFSTestRepository(t, "lfs-upload-repo")
|
||||
oid := storeObjectInRepo(t, repo.ID, "dummy3")
|
||||
@ -428,8 +424,7 @@ func TestAPILFSUpload(t *testing.T) {
|
||||
|
||||
func TestAPILFSVerify(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.LFS.StartServer = true
|
||||
defer test.MockVariableValue(&setting.LFS.StartServer, true)()
|
||||
|
||||
repo := createLFSTestRepository(t, "lfs-verify-repo")
|
||||
oid := storeObjectInRepo(t, repo.ID, "dummy3")
|
||||
|
||||
@ -8,6 +8,9 @@ set -euo pipefail
|
||||
|
||||
tags=${1:?usage: $0 TAGS}
|
||||
|
||||
# Exclusions mirror the Makefile's GO_TEST_PACKAGES filter — these packages
|
||||
# need a real database / dedicated harness and are tested separately.
|
||||
go list -tags "$tags" -f '{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}|{{range .Imports}}{{.}};{{end}}{{range .TestImports}}{{.}};{{end}}{{range .XTestImports}}{{.}};{{end}}{{end}}' ./... \
|
||||
| awk -F'|' '$2 ~ /code\.gitea\.io\/gitea\/modules\/(git|gitrepo|lfs)([\.\/;]|$)/ { print $1 }' \
|
||||
| grep -vE '^code\.gitea\.io/gitea/(models/migrations(/|$)|tests(/integration(/migration-test)?)?$)' \
|
||||
| sort -u
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user