Skip to content

Commit fd18427

Browse files
committed
fix test
1 parent f71042b commit fd18427

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

integrations/api_repo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func testAPIRepoMigrateConflict(t *testing.T, u *url.URL) {
334334
resp := httpContext.Session.MakeRequest(t, req, http.StatusConflict)
335335
respJSON := map[string]string{}
336336
DecodeJSON(t, resp, &respJSON)
337-
assert.Equal(t, "repository already exists [uname: user2, name: repo-tmp-17]", respJSON["message"])
337+
assert.Equal(t, "The repository with the same name already exists.", respJSON["message"])
338338
})
339339
}
340340

routers/api/v1/repo/repo.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
436436
Status: models.RepositoryBeingMigrated,
437437
})
438438
if err != nil {
439-
ctx.Error(500, "CreateRepository", err)
439+
handleMigrateError(ctx, remoteAddr, err)
440440
return
441441
}
442442

@@ -472,6 +472,10 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
472472
return
473473
}
474474

475+
handleMigrateError(ctx, remoteAddr, err)
476+
}
477+
478+
func handleMigrateError(ctx *context.APIContext, remoteAddr string, err error) {
475479
switch {
476480
case models.IsErrRepoAlreadyExist(err):
477481
ctx.Error(409, "", "The repository with the same name already exists.")
@@ -480,7 +484,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
480484
case migrations.IsTwoFactorAuthError(err):
481485
ctx.Error(422, "", "Remote visit required two factors authentication.")
482486
case models.IsErrReachLimitOfRepo(err):
483-
ctx.Error(422, "", fmt.Sprintf("You have already reached your limit of %d repositories.", ctxUser.MaxCreationLimit()))
487+
ctx.Error(422, "", fmt.Sprintf("You have already reached your limit of %d repositories.", ctx.User.MaxCreationLimit()))
484488
case models.IsErrNameReserved(err):
485489
ctx.Error(422, "", fmt.Sprintf("The username '%s' is reserved.", err.(models.ErrNameReserved).Name))
486490
case models.IsErrNamePatternNotAllowed(err):

0 commit comments

Comments
 (0)