Refactor integration tests infrastructure (#37462)

Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-04-29 18:37:38 +02:00
committed by GitHub
parent 9262803621
commit d57d06335d
26 changed files with 331 additions and 544 deletions
+4 -2
View File
@@ -7,9 +7,11 @@ import (
"encoding/base64"
"net/http"
"os"
"path/filepath"
"testing"
auth_model "code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/tests"
@@ -24,7 +26,7 @@ func TestAPIUpdateUserAvatar(t *testing.T) {
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteUser)
// Test what happens if you use a valid image
avatar, err := os.ReadFile("tests/integration/avatar.png")
avatar, err := os.ReadFile(filepath.Join(setting.GetGiteaTestSourceRoot(), "tests/integration/avatar.png"))
assert.NoError(t, err)
if err != nil {
assert.FailNow(t, "Unable to open avatar.png")
@@ -48,7 +50,7 @@ func TestAPIUpdateUserAvatar(t *testing.T) {
MakeRequest(t, req, http.StatusBadRequest)
// Test what happens if you use a file that is not an image
text, err := os.ReadFile("tests/integration/README.md")
text, err := os.ReadFile(filepath.Join(setting.GetGiteaTestSourceRoot(), "tests/integration/README.md"))
assert.NoError(t, err)
if err != nil {
assert.FailNow(t, "Unable to open README.md")