tests/integration: simplify code (#37249)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
This commit is contained in:
Copilot
2026-04-17 20:33:49 +08:00
committed by GitHub
parent dc974715e9
commit eb334e3738
23 changed files with 168 additions and 279 deletions
@@ -4,7 +4,6 @@
package integration
import (
"archive/zip"
"bytes"
"fmt"
"net/http"
@@ -17,6 +16,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
composer_module "code.gitea.io/gitea/modules/packages/composer"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/test"
"code.gitea.io/gitea/routers/api/packages/composer"
"code.gitea.io/gitea/tests"
@@ -38,10 +38,8 @@ func TestPackageComposer(t *testing.T) {
packageLicense := "MIT"
packageBin := "./bin/script"
var buf bytes.Buffer
archive := zip.NewWriter(&buf)
w, _ := archive.Create("composer.json")
w.Write([]byte(`{
content := test.WriteZipArchive(map[string]string{
"composer.json": `{
"name": "` + packageName + `",
"description": "` + packageDescription + `",
"type": "` + packageType + `",
@@ -54,9 +52,8 @@ func TestPackageComposer(t *testing.T) {
"bin": [
"` + packageBin + `"
]
}`))
archive.Close()
content := buf.Bytes()
}`,
}).Bytes()
url := fmt.Sprintf("%sapi/packages/%s/composer", setting.AppURL, user.Name)