summaryrefslogtreecommitdiffstats
path: root/models/access_test.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-01-08 22:08:36 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-01-09 11:08:36 +0800
commit4b23e6a69449b985c74ad797257c30250e60ec9a (patch)
treec4766acb1d3d2b8dfd0d9253cabcfb3a0ba38a6c /models/access_test.go
parentf4feeecc3af089a105c9a1ad976a78cd6856b407 (diff)
downloadgitea-4b23e6a69449b985c74ad797257c30250e60ec9a.tar.gz
gitea-4b23e6a69449b985c74ad797257c30250e60ec9a.zip
Unit tests for models/action (#619)
Diffstat (limited to 'models/access_test.go')
-rw-r--r--models/access_test.go28
1 files changed, 14 insertions, 14 deletions
diff --git a/models/access_test.go b/models/access_test.go
index c9847f0069..a2e59b3e96 100644
--- a/models/access_test.go
+++ b/models/access_test.go
@@ -19,10 +19,10 @@ var accessModes = []AccessMode{
func TestAccessLevel(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
- user1 := &User{ID: 2}; LoadTestFixture(t, user1)
- user2 := &User{ID: 4}; LoadTestFixture(t, user2)
- repo1 := &Repository{OwnerID: 2, IsPrivate: false}; LoadTestFixture(t, repo1)
- repo2 := &Repository{OwnerID: 3, IsPrivate: true}; LoadTestFixture(t, repo2)
+ user1 := &User{ID: 2}; AssertExistsAndLoadBean(t, user1)
+ user2 := &User{ID: 4}; AssertExistsAndLoadBean(t, user2)
+ repo1 := &Repository{OwnerID: 2, IsPrivate: false}; AssertExistsAndLoadBean(t, repo1)
+ repo2 := &Repository{OwnerID: 3, IsPrivate: true}; AssertExistsAndLoadBean(t, repo2)
level, err := AccessLevel(user1, repo1)
assert.NoError(t, err)
@@ -44,10 +44,10 @@ func TestAccessLevel(t *testing.T) {
func TestHasAccess(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
- user1 := &User{ID: 2}; LoadTestFixture(t, user1)
- user2 := &User{ID: 4}; LoadTestFixture(t, user2)
- repo1 := &Repository{OwnerID: 2, IsPrivate: false}; LoadTestFixture(t, repo1)
- repo2 := &Repository{OwnerID: 3, IsPrivate: true}; LoadTestFixture(t, repo2)
+ user1 := &User{ID: 2}; AssertExistsAndLoadBean(t, user1)
+ user2 := &User{ID: 4}; AssertExistsAndLoadBean(t, user2)
+ repo1 := &Repository{OwnerID: 2, IsPrivate: false}; AssertExistsAndLoadBean(t, repo1)
+ repo2 := &Repository{OwnerID: 3, IsPrivate: true}; AssertExistsAndLoadBean(t, repo2)
for _, accessMode := range accessModes {
has, err := HasAccess(user1, repo1, accessMode)
@@ -71,8 +71,8 @@ func TestHasAccess(t *testing.T) {
func TestUser_GetRepositoryAccesses(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
- user1 := &User{ID: 1}; LoadTestFixture(t, user1)
- user2 := &User{ID: 2}; LoadTestFixture(t, user2)
+ user1 := &User{ID: 1}; AssertExistsAndLoadBean(t, user1)
+ user2 := &User{ID: 2}; AssertExistsAndLoadBean(t, user2)
accesses, err := user1.GetRepositoryAccesses()
assert.NoError(t, err)
@@ -82,8 +82,8 @@ func TestUser_GetRepositoryAccesses(t *testing.T) {
func TestUser_GetAccessibleRepositories(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
- user1 := &User{ID: 1}; LoadTestFixture(t, user1)
- user2 := &User{ID: 2}; LoadTestFixture(t, user2)
+ user1 := &User{ID: 1}; AssertExistsAndLoadBean(t, user1)
+ user2 := &User{ID: 2}; AssertExistsAndLoadBean(t, user2)
repos, err := user1.GetAccessibleRepositories(0)
assert.NoError(t, err)
@@ -98,7 +98,7 @@ func TestUser_GetAccessibleRepositories(t *testing.T) {
func TestRepository_RecalculateAccesses(t *testing.T) {
// test with organization repo
assert.NoError(t, PrepareTestDatabase())
- repo1 := &Repository{ID: 3}; LoadTestFixture(t, repo1)
+ repo1 := &Repository{ID: 3}; AssertExistsAndLoadBean(t, repo1)
assert.NoError(t, repo1.GetOwner())
sess := x.NewSession()
@@ -119,7 +119,7 @@ func TestRepository_RecalculateAccesses(t *testing.T) {
func TestRepository_RecalculateAccesses2(t *testing.T) {
// test with non-organization repo
assert.NoError(t, PrepareTestDatabase())
- repo1 := &Repository{ID: 4}; LoadTestFixture(t, repo1)
+ repo1 := &Repository{ID: 4}; AssertExistsAndLoadBean(t, repo1)
assert.NoError(t, repo1.GetOwner())
sess := x.NewSession()