Skip to content

Commit 573b497

Browse files
committed
adjust tests (8)
1 parent 3559d2f commit 573b497

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/integration/migrate_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,19 @@ func TestMigrateGiteaForm(t *testing.T) {
7373

7474
// Step 0: verify the repo is available
7575
req := NewRequestf(t, "GET", "/%s/%s", ownerName, repoName)
76-
_ = session.MakeRequest(t, req, http.StatusOK)
76+
resp := session.MakeRequest(t, req, http.StatusMovedPermanently)
77+
req = NewRequest(t, "GET", resp.Result().Header.Get("Location"))
78+
_ = MakeRequest(t, req, http.StatusOK)
79+
7780
// Step 1: get the Gitea migration form
7881
req = NewRequestf(t, "GET", "/repo/migrate/?service_type=%d", structs.GiteaService)
79-
resp := session.MakeRequest(t, req, http.StatusOK)
82+
resp = session.MakeRequest(t, req, http.StatusOK)
83+
8084
// Step 2: load the form
8185
htmlDoc := NewHTMLParser(t, resp.Body)
8286
link, exists := htmlDoc.doc.Find(`form.ui.form[action^="/repo/migrate"]`).Attr("action")
8387
assert.True(t, exists, "The template has changed")
88+
8489
// Step 4: submit the migration to only migrate issues
8590
migratedRepoName := "otherrepo"
8691
req = NewRequestWithValues(t, "POST", link, map[string]string{
@@ -94,9 +99,11 @@ func TestMigrateGiteaForm(t *testing.T) {
9499
"uid": fmt.Sprintf("%d", repoOwner.ID),
95100
})
96101
resp = session.MakeRequest(t, req, http.StatusSeeOther)
102+
97103
// Step 5: a redirection displays the migrated repository
98104
loc := resp.Header().Get("Location")
99105
assert.EqualValues(t, fmt.Sprintf("/%s/%s", ownerName, migratedRepoName), loc)
106+
100107
// Step 6: check the repo was created
101108
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: migratedRepoName})
102109
})

0 commit comments

Comments
 (0)