db: add tests for repos (#6112)

* Add Repos.create method

* Fix repo name error handling

* Fix all compile errors

* Update github.com/go-macaron/captcha to fix http issue

* Add repos tests
This commit is contained in:
ᴜɴᴋɴᴡᴏɴ
2020-04-17 10:14:18 +08:00
committed by GitHub
parent e131a45646
commit fa497b1633
23 changed files with 302 additions and 170 deletions

View File

@@ -31,8 +31,7 @@ func CreateOrgForUser(c *context.APIContext, apiForm api.CreateOrgOption, user *
}
if err := db.CreateOrganization(org, user); err != nil {
if db.IsErrUserAlreadyExist(err) ||
db.IsErrNameReserved(err) ||
db.IsErrNamePatternNotAllowed(err) {
db.IsErrNameNotAllowed(err) {
c.ErrorStatus(http.StatusUnprocessableEntity, err)
} else {
c.Error(err, "create organization")