mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-23 23:14:32 +02:00
refactor: clean up git migration forms (#39672)
Only extracted shared code, removed unnecessary code, and use form-fetch-action to replace RenderWithErrDeprecated, slightly refactored JS to use data-global-init Nothing else is changed, although there are still many problems. Written by AI Diff with hiding spaces: https://github.com/go-gitea/gitea/pull/39672/changes?w=1
This commit is contained in:
1 parent
89ec271d9c
commit
cc623c5f2f
18 files changed
+274
-724
No files matched your search
@@ -94,9 +94,9 @@ func TestMigrateGiteaForm(t *testing.T) {
|
||||
"description": "",
|
||||
"uid": strconv.FormatInt(repoOwner.ID, 10),
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
// Step 5: a redirection displays the migrated repository
|
||||
loc := resp.Header().Get("Location")
|
||||
loc := *test.ParseJSONRedirect(resp.Body.Bytes()).Redirect
|
||||
assert.Equal(t, fmt.Sprintf("/%s/%s", ownerName, migratedRepoName), loc)
|
||||
// Step 6: check the repo was created
|
||||
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: migratedRepoName})
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"gitea.dev/modules/structs"
|
||||
"gitea.dev/modules/test"
|
||||
"gitea.dev/tests"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -23,7 +24,7 @@ func testRepoMigrate(t testing.TB, session *TestSession, cloneAddr, repoName str
|
||||
link, exists := htmlDoc.doc.Find("form.ui.form").Attr("action")
|
||||
assert.True(t, exists, "The template has changed")
|
||||
|
||||
uid, exists := htmlDoc.doc.Find("#uid").Attr("value")
|
||||
uid, exists := htmlDoc.doc.Find(`input[name="uid"]`).Attr("value")
|
||||
assert.True(t, exists, "The template has changed")
|
||||
|
||||
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||||
@@ -32,7 +33,7 @@ func testRepoMigrate(t testing.TB, session *TestSession, cloneAddr, repoName str
|
||||
"repo_name": repoName,
|
||||
"service": fmt.Sprintf("%d", structs.PlainGitService),
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
return resp
|
||||
}
|
||||
@@ -40,5 +41,6 @@ func testRepoMigrate(t testing.TB, session *TestSession, cloneAddr, repoName str
|
||||
func TestRepoMigrate(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
session := loginUser(t, "user2")
|
||||
testRepoMigrate(t, session, "https://github.com/go-gitea/test_repo.git", "git")
|
||||
resp := testRepoMigrate(t, session, "https://github.com/go-gitea/test_repo.git", "git")
|
||||
assert.Equal(t, "/user2/git", *test.ParseJSONRedirect(resp.Body.Bytes()).Redirect)
|
||||
}
|
||||
Reference in new issue
Block a user