summaryrefslogtreecommitdiffstats
path: root/models/repo_test.go
diff options
context:
space:
mode:
authorBo-Yi Wu <appleboy.tw@gmail.com>2017-02-15 23:24:23 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-15 23:24:23 +0800
commit43c94d0a6cd8daf01125df3bf895f1beb1bcd664 (patch)
tree06973f77f683d30f3efab45a5f2d9e5a9c9c7726 /models/repo_test.go
parenta31f64d639f32ee4ef428e76277eb0b0bf5616c4 (diff)
downloadgitea-43c94d0a6cd8daf01125df3bf895f1beb1bcd664.tar.gz
gitea-43c94d0a6cd8daf01125df3bf895f1beb1bcd664.zip
test: Add testing for GetUserFork function (#944)
Diffstat (limited to 'models/repo_test.go')
-rw-r--r--models/repo_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/models/repo_test.go b/models/repo_test.go
index 18da682059..7c0e94a5ae 100644
--- a/models/repo_test.go
+++ b/models/repo_test.go
@@ -92,3 +92,36 @@ func TestUpdateRepositoryVisibilityChanged(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, true, act.IsPrivate)
}
+
+func TestGetUserFork(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ // User13 has repo 11 forked from repo10
+ repo, err := GetRepositoryByID(10)
+ assert.NoError(t, err)
+ assert.NotNil(t, repo)
+ repo, err = repo.GetUserFork(13)
+ assert.NoError(t, err)
+ assert.NotNil(t, repo)
+
+ repo, err = GetRepositoryByID(9)
+ assert.NoError(t, err)
+ assert.NotNil(t, repo)
+ repo, err = repo.GetUserFork(13)
+ assert.NoError(t, err)
+ assert.Nil(t, repo)
+}
+
+func TestForkRepository(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ // User13 has repo 11 forked from repo10
+ repo, err := GetRepositoryByID(10)
+ assert.NoError(t, err)
+ assert.NotNil(t, repo)
+
+ repo, err = ForkRepository(&User{ID: 13}, repo, "test", "test")
+ assert.Nil(t, repo)
+ assert.Error(t, err)
+ assert.True(t, IsErrRepoAlreadyExist(err))
+}