summaryrefslogtreecommitdiffstats
path: root/models/user_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-10-09 01:55:16 +0800
committerLauris BH <lauris@nix.lv>2019-10-08 20:55:16 +0300
commit170743c8a0cdf216ee21076aadc5d905dfef0cd6 (patch)
treea5b58a617e6afcfb1fc20044a87cc8f34465d5b2 /models/user_test.go
parent78438d310be42f9c5e0e2937ee54e6050cc8f381 (diff)
downloadgitea-170743c8a0cdf216ee21076aadc5d905dfef0cd6.tar.gz
gitea-170743c8a0cdf216ee21076aadc5d905dfef0cd6.zip
Revert "Fix issues/pr list broken when there are many repositories (#8409)" (#8427)
This reverts commit 78438d310be42f9c5e0e2937ee54e6050cc8f381.
Diffstat (limited to 'models/user_test.go')
-rw-r--r--models/user_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/models/user_test.go b/models/user_test.go
index 75d806eadc..bcb955817c 100644
--- a/models/user_test.go
+++ b/models/user_test.go
@@ -275,6 +275,28 @@ func BenchmarkHashPassword(b *testing.B) {
}
}
+func TestGetOrgRepositoryIDs(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+ user2 := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ user4 := AssertExistsAndLoadBean(t, &User{ID: 4}).(*User)
+ user5 := AssertExistsAndLoadBean(t, &User{ID: 5}).(*User)
+
+ accessibleRepos, err := user2.GetOrgRepositoryIDs()
+ assert.NoError(t, err)
+ // User 2's team has access to private repos 3, 5, repo 32 is a public repo of the organization
+ assert.Equal(t, []int64{3, 5, 23, 24, 32}, accessibleRepos)
+
+ accessibleRepos, err = user4.GetOrgRepositoryIDs()
+ assert.NoError(t, err)
+ // User 4's team has access to private repo 3, repo 32 is a public repo of the organization
+ assert.Equal(t, []int64{3, 32}, accessibleRepos)
+
+ accessibleRepos, err = user5.GetOrgRepositoryIDs()
+ assert.NoError(t, err)
+ // User 5's team has no access to any repo
+ assert.Len(t, accessibleRepos, 0)
+}
+
func TestNewGitSig(t *testing.T) {
users := make([]*User, 0, 20)
sess := x.NewSession()