summaryrefslogtreecommitdiffstats
path: root/modules/repository/fork_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2020-01-12 20:11:17 +0800
committerGitHub <noreply@github.com>2020-01-12 20:11:17 +0800
commitb465d0d78793da6e67890a7cb9d3ae1b807c53ca (patch)
tree1cdfb83699ad2fd31d5835bb2ac1e1b579eaf784 /modules/repository/fork_test.go
parent5765212c6dbcaeb27779707af3ca57775e535bd9 (diff)
downloadgitea-b465d0d78793da6e67890a7cb9d3ae1b807c53ca.tar.gz
gitea-b465d0d78793da6e67890a7cb9d3ae1b807c53ca.zip
Move create/fork repository from models to modules/repository (#9489)
* Move create/fork repository from models to modules/repository * fix wrong reference * fix test * fix test * fix lint * Fix DBContext * remove duplicated TestMain * fix lint * fix conflicts
Diffstat (limited to 'modules/repository/fork_test.go')
-rw-r--r--modules/repository/fork_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/modules/repository/fork_test.go b/modules/repository/fork_test.go
new file mode 100644
index 0000000000..cb3526bccf
--- /dev/null
+++ b/modules/repository/fork_test.go
@@ -0,0 +1,25 @@
+// Copyright 2017 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package repository
+
+import (
+ "testing"
+
+ "code.gitea.io/gitea/models"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestForkRepository(t *testing.T) {
+ assert.NoError(t, models.PrepareTestDatabase())
+
+ // user 13 has already forked repo10
+ user := models.AssertExistsAndLoadBean(t, &models.User{ID: 13}).(*models.User)
+ repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 10}).(*models.Repository)
+
+ fork, err := ForkRepository(user, user, repo, "test", "test")
+ assert.Nil(t, fork)
+ assert.Error(t, err)
+ assert.True(t, models.IsErrForkAlreadyExist(err))
+}