chore(ci): use code.forgejo.org/forgejo/migration-test for migration tests (#8157)

Using https://github.com/go-gitea/test_repo is not necessary as the current API integration tests are not GitHub specific. It makes them less susceptible to transient failures because of throttling.

---

The https://code.forgejo.org/forgejo/migration-test repository was created just now. There still is a chance (although very slim) that someone running the CI will be throttled by code.forgejo.org and the error message suggesting that may be a cause for failure is kept to clear the confusion in case it happens.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8157
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-06-11 20:25:32 +02:00 committed by Earl Warren
parent 7958942e3e
commit 32300d5488

View file

@ -376,11 +376,11 @@ func TestAPIRepoMigrate(t *testing.T) {
cloneURL, repoName string
expectedStatus int
}{
{ctxUserID: 1, userID: 2, cloneURL: "https://github.com/go-gitea/test_repo.git", repoName: "git-admin", expectedStatus: http.StatusCreated},
{ctxUserID: 2, userID: 2, cloneURL: "https://github.com/go-gitea/test_repo.git", repoName: "git-own", expectedStatus: http.StatusCreated},
{ctxUserID: 2, userID: 1, cloneURL: "https://github.com/go-gitea/test_repo.git", repoName: "git-bad", expectedStatus: http.StatusForbidden},
{ctxUserID: 2, userID: 3, cloneURL: "https://github.com/go-gitea/test_repo.git", repoName: "git-org", expectedStatus: http.StatusCreated},
{ctxUserID: 2, userID: 6, cloneURL: "https://github.com/go-gitea/test_repo.git", repoName: "git-bad-org", expectedStatus: http.StatusForbidden},
{ctxUserID: 1, userID: 2, cloneURL: "https://code.forgejo.org/forgejo/migration-test.git", repoName: "git-admin", expectedStatus: http.StatusCreated},
{ctxUserID: 2, userID: 2, cloneURL: "https://code.forgejo.org/forgejo/migration-test.git", repoName: "git-own", expectedStatus: http.StatusCreated},
{ctxUserID: 2, userID: 1, cloneURL: "https://code.forgejo.org/forgejo/migration-test.git", repoName: "git-bad", expectedStatus: http.StatusForbidden},
{ctxUserID: 2, userID: 3, cloneURL: "https://code.forgejo.org/forgejo/migration-test.git", repoName: "git-org", expectedStatus: http.StatusCreated},
{ctxUserID: 2, userID: 6, cloneURL: "https://code.forgejo.org/forgejo/migration-test.git", repoName: "git-bad-org", expectedStatus: http.StatusForbidden},
{ctxUserID: 2, userID: 3, cloneURL: "https://localhost:3000/user/test_repo.git", repoName: "private-ip", expectedStatus: http.StatusUnprocessableEntity},
{ctxUserID: 2, userID: 3, cloneURL: "https://10.0.0.1/user/test_repo.git", repoName: "private-ip", expectedStatus: http.StatusUnprocessableEntity},
}
@ -396,20 +396,7 @@ func TestAPIRepoMigrate(t *testing.T) {
RepoName: testCase.repoName,
}).AddTokenAuth(token)
resp := MakeRequest(t, req, NoExpectedStatus)
if resp.Code == http.StatusUnprocessableEntity {
respJSON := map[string]string{}
DecodeJSON(t, resp, &respJSON)
switch respJSON["message"] {
case "Remote visit addressed rate limitation.":
t.Log("test hit github rate limitation")
case "You can not import from disallowed hosts.":
assert.Equal(t, "private-ip", testCase.repoName)
default:
assert.FailNow(t, "unexpected error", "'%v' on url '%s'", respJSON["message"], testCase.cloneURL)
}
} else {
assert.Equal(t, testCase.expectedStatus, resp.Code)
}
require.Equalf(t, testCase.expectedStatus, resp.Code, "unexpected status (may be due to throttling): '%v' on url '%s'", resp.Body.String(), testCase.cloneURL)
}
}
@ -433,7 +420,7 @@ func testAPIRepoMigrateConflict(t *testing.T, u *url.URL) {
require.NoError(t, err)
userID := user.ID
cloneURL := "https://github.com/go-gitea/test_repo.git"
cloneURL := "https://code.forgejo.org/forgejo/migration-test.git"
req := NewRequestWithJSON(t, "POST", "/api/v1/repos/migrate",
&api.MigrateRepoOptions{