Fix 500 error when error occurred in migration page (#33256)

The template should be `repo/migrate/{service type}`
But input element `service` is not in the form.

Related: #33081

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
yp05327 2025-01-14 15:29:44 +09:00 committed by GitHub
parent 4672ddcdd7
commit 3a749fc816
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 32 additions and 10 deletions

View file

@ -79,8 +79,12 @@ func TestMigrateGiteaForm(t *testing.T) {
resp := session.MakeRequest(t, req, http.StatusOK)
// Step 2: load the form
htmlDoc := NewHTMLParser(t, resp.Body)
link, exists := htmlDoc.doc.Find(`form.ui.form[action^="/repo/migrate"]`).Attr("action")
form := htmlDoc.doc.Find(`form.ui.form[action^="/repo/migrate"]`)
link, exists := form.Attr("action")
assert.True(t, exists, "The template has changed")
serviceInput, exists := form.Find(`input[name="service"]`).Attr("value")
assert.True(t, exists)
assert.EqualValues(t, fmt.Sprintf("%d", structs.GiteaService), serviceInput)
// Step 4: submit the migration to only migrate issues
migratedRepoName := "otherrepo"
req = NewRequestWithValues(t, "POST", link, map[string]string{