aboutsummaryrefslogtreecommitdiffstats
path: root/models/org_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/org_test.go')
-rw-r--r--models/org_test.go184
1 files changed, 92 insertions, 92 deletions
diff --git a/models/org_test.go b/models/org_test.go
index 9557e14edc..2bc4d74fc3 100644
--- a/models/org_test.go
+++ b/models/org_test.go
@@ -29,7 +29,7 @@ func TestUser_IsOwnedBy(t *testing.T) {
{2, 2, false}, // user2 is not an organization
{2, 3, false},
} {
- org := db.AssertExistsAndLoadBean(t, &User{ID: testCase.OrgID}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: testCase.OrgID}).(*User)
isOwner, err := org.IsOwnedBy(testCase.UserID)
assert.NoError(t, err)
assert.Equal(t, testCase.ExpectedOwner, isOwner)
@@ -50,7 +50,7 @@ func TestUser_IsOrgMember(t *testing.T) {
{2, 2, false}, // user2 is not an organization
{2, 3, false},
} {
- org := db.AssertExistsAndLoadBean(t, &User{ID: testCase.OrgID}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: testCase.OrgID}).(*User)
isMember, err := org.IsOrgMember(testCase.UserID)
assert.NoError(t, err)
assert.Equal(t, testCase.ExpectedMember, isMember)
@@ -59,7 +59,7 @@ func TestUser_IsOrgMember(t *testing.T) {
func TestUser_GetTeam(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
team, err := org.GetTeam("team1")
assert.NoError(t, err)
assert.Equal(t, org.ID, team.OrgID)
@@ -68,26 +68,26 @@ func TestUser_GetTeam(t *testing.T) {
_, err = org.GetTeam("does not exist")
assert.True(t, IsErrTeamNotExist(err))
- nonOrg := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ nonOrg := unittest.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
_, err = nonOrg.GetTeam("team")
assert.True(t, IsErrTeamNotExist(err))
}
func TestUser_GetOwnerTeam(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
team, err := org.GetOwnerTeam()
assert.NoError(t, err)
assert.Equal(t, org.ID, team.OrgID)
- nonOrg := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ nonOrg := unittest.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
_, err = nonOrg.GetOwnerTeam()
assert.True(t, IsErrTeamNotExist(err))
}
func TestUser_GetTeams(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
assert.NoError(t, org.LoadTeams())
if assert.Len(t, org.Teams, 4) {
assert.Equal(t, int64(1), org.Teams[0].ID)
@@ -99,7 +99,7 @@ func TestUser_GetTeams(t *testing.T) {
func TestUser_GetMembers(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
assert.NoError(t, org.GetMembers())
if assert.Len(t, org.Members, 3) {
assert.Equal(t, int64(2), org.Members[0].ID)
@@ -110,68 +110,68 @@ func TestUser_GetMembers(t *testing.T) {
func TestUser_AddMember(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
// add a user that is not a member
- db.AssertNotExistsBean(t, &OrgUser{UID: 5, OrgID: 3})
+ unittest.AssertNotExistsBean(t, &OrgUser{UID: 5, OrgID: 3})
prevNumMembers := org.NumMembers
assert.NoError(t, org.AddMember(5))
- db.AssertExistsAndLoadBean(t, &OrgUser{UID: 5, OrgID: 3})
- org = db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ unittest.AssertExistsAndLoadBean(t, &OrgUser{UID: 5, OrgID: 3})
+ org = unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
assert.Equal(t, prevNumMembers+1, org.NumMembers)
// add a user that is already a member
- db.AssertExistsAndLoadBean(t, &OrgUser{UID: 4, OrgID: 3})
+ unittest.AssertExistsAndLoadBean(t, &OrgUser{UID: 4, OrgID: 3})
prevNumMembers = org.NumMembers
assert.NoError(t, org.AddMember(4))
- db.AssertExistsAndLoadBean(t, &OrgUser{UID: 4, OrgID: 3})
- org = db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ unittest.AssertExistsAndLoadBean(t, &OrgUser{UID: 4, OrgID: 3})
+ org = unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
assert.Equal(t, prevNumMembers, org.NumMembers)
- CheckConsistencyFor(t, &User{})
+ unittest.CheckConsistencyFor(t, &User{})
}
func TestUser_RemoveMember(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
// remove a user that is a member
- db.AssertExistsAndLoadBean(t, &OrgUser{UID: 4, OrgID: 3})
+ unittest.AssertExistsAndLoadBean(t, &OrgUser{UID: 4, OrgID: 3})
prevNumMembers := org.NumMembers
assert.NoError(t, org.RemoveMember(4))
- db.AssertNotExistsBean(t, &OrgUser{UID: 4, OrgID: 3})
- org = db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ unittest.AssertNotExistsBean(t, &OrgUser{UID: 4, OrgID: 3})
+ org = unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
assert.Equal(t, prevNumMembers-1, org.NumMembers)
// remove a user that is not a member
- db.AssertNotExistsBean(t, &OrgUser{UID: 5, OrgID: 3})
+ unittest.AssertNotExistsBean(t, &OrgUser{UID: 5, OrgID: 3})
prevNumMembers = org.NumMembers
assert.NoError(t, org.RemoveMember(5))
- db.AssertNotExistsBean(t, &OrgUser{UID: 5, OrgID: 3})
- org = db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ unittest.AssertNotExistsBean(t, &OrgUser{UID: 5, OrgID: 3})
+ org = unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
assert.Equal(t, prevNumMembers, org.NumMembers)
- CheckConsistencyFor(t, &User{}, &Team{})
+ unittest.CheckConsistencyFor(t, &User{}, &Team{})
}
func TestUser_RemoveOrgRepo(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
- repo := db.AssertExistsAndLoadBean(t, &Repository{OwnerID: org.ID}).(*Repository)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ repo := unittest.AssertExistsAndLoadBean(t, &Repository{OwnerID: org.ID}).(*Repository)
// remove a repo that does belong to org
- db.AssertExistsAndLoadBean(t, &TeamRepo{RepoID: repo.ID, OrgID: org.ID})
+ unittest.AssertExistsAndLoadBean(t, &TeamRepo{RepoID: repo.ID, OrgID: org.ID})
assert.NoError(t, org.RemoveOrgRepo(repo.ID))
- db.AssertNotExistsBean(t, &TeamRepo{RepoID: repo.ID, OrgID: org.ID})
- db.AssertExistsAndLoadBean(t, &Repository{ID: repo.ID}) // repo should still exist
+ unittest.AssertNotExistsBean(t, &TeamRepo{RepoID: repo.ID, OrgID: org.ID})
+ unittest.AssertExistsAndLoadBean(t, &Repository{ID: repo.ID}) // repo should still exist
// remove a repo that does not belong to org
assert.NoError(t, org.RemoveOrgRepo(repo.ID))
- db.AssertNotExistsBean(t, &TeamRepo{RepoID: repo.ID, OrgID: org.ID})
+ unittest.AssertNotExistsBean(t, &TeamRepo{RepoID: repo.ID, OrgID: org.ID})
- assert.NoError(t, org.RemoveOrgRepo(db.NonexistentID))
+ assert.NoError(t, org.RemoveOrgRepo(unittest.NonexistentID))
- CheckConsistencyFor(t,
+ unittest.CheckConsistencyFor(t,
&User{ID: org.ID},
&Team{OrgID: org.ID},
&Repository{ID: repo.ID})
@@ -181,62 +181,62 @@ func TestCreateOrganization(t *testing.T) {
// successful creation of org
assert.NoError(t, unittest.PrepareTestDatabase())
- owner := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ owner := unittest.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
const newOrgName = "neworg"
org := &User{
Name: newOrgName,
}
- db.AssertNotExistsBean(t, &User{Name: newOrgName, Type: UserTypeOrganization})
+ unittest.AssertNotExistsBean(t, &User{Name: newOrgName, Type: UserTypeOrganization})
assert.NoError(t, CreateOrganization(org, owner))
- org = db.AssertExistsAndLoadBean(t,
+ org = unittest.AssertExistsAndLoadBean(t,
&User{Name: newOrgName, Type: UserTypeOrganization}).(*User)
- ownerTeam := db.AssertExistsAndLoadBean(t,
+ ownerTeam := unittest.AssertExistsAndLoadBean(t,
&Team{Name: ownerTeamName, OrgID: org.ID}).(*Team)
- db.AssertExistsAndLoadBean(t, &TeamUser{UID: owner.ID, TeamID: ownerTeam.ID})
- CheckConsistencyFor(t, &User{}, &Team{})
+ unittest.AssertExistsAndLoadBean(t, &TeamUser{UID: owner.ID, TeamID: ownerTeam.ID})
+ unittest.CheckConsistencyFor(t, &User{}, &Team{})
}
func TestCreateOrganization2(t *testing.T) {
// unauthorized creation of org
assert.NoError(t, unittest.PrepareTestDatabase())
- owner := db.AssertExistsAndLoadBean(t, &User{ID: 5}).(*User)
+ owner := unittest.AssertExistsAndLoadBean(t, &User{ID: 5}).(*User)
const newOrgName = "neworg"
org := &User{
Name: newOrgName,
}
- db.AssertNotExistsBean(t, &User{Name: newOrgName, Type: UserTypeOrganization})
+ unittest.AssertNotExistsBean(t, &User{Name: newOrgName, Type: UserTypeOrganization})
err := CreateOrganization(org, owner)
assert.Error(t, err)
assert.True(t, IsErrUserNotAllowedCreateOrg(err))
- db.AssertNotExistsBean(t, &User{Name: newOrgName, Type: UserTypeOrganization})
- CheckConsistencyFor(t, &User{}, &Team{})
+ unittest.AssertNotExistsBean(t, &User{Name: newOrgName, Type: UserTypeOrganization})
+ unittest.CheckConsistencyFor(t, &User{}, &Team{})
}
func TestCreateOrganization3(t *testing.T) {
// create org with same name as existent org
assert.NoError(t, unittest.PrepareTestDatabase())
- owner := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
- org := &User{Name: "user3"} // should already exist
- db.AssertExistsAndLoadBean(t, &User{Name: org.Name}) // sanity check
+ owner := unittest.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ org := &User{Name: "user3"} // should already exist
+ unittest.AssertExistsAndLoadBean(t, &User{Name: org.Name}) // sanity check
err := CreateOrganization(org, owner)
assert.Error(t, err)
assert.True(t, IsErrUserAlreadyExist(err))
- CheckConsistencyFor(t, &User{}, &Team{})
+ unittest.CheckConsistencyFor(t, &User{}, &Team{})
}
func TestCreateOrganization4(t *testing.T) {
// create org with unusable name
assert.NoError(t, unittest.PrepareTestDatabase())
- owner := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ owner := unittest.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
err := CreateOrganization(&User{Name: "assets"}, owner)
assert.Error(t, err)
assert.True(t, IsErrNameReserved(err))
- CheckConsistencyFor(t, &User{}, &Team{})
+ unittest.CheckConsistencyFor(t, &User{}, &Team{})
}
func TestGetOrgByName(t *testing.T) {
@@ -263,20 +263,20 @@ func TestCountOrganizations(t *testing.T) {
func TestDeleteOrganization(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 6}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 6}).(*User)
assert.NoError(t, DeleteOrganization(org))
- db.AssertNotExistsBean(t, &User{ID: 6})
- db.AssertNotExistsBean(t, &OrgUser{OrgID: 6})
- db.AssertNotExistsBean(t, &Team{OrgID: 6})
+ unittest.AssertNotExistsBean(t, &User{ID: 6})
+ unittest.AssertNotExistsBean(t, &OrgUser{OrgID: 6})
+ unittest.AssertNotExistsBean(t, &Team{OrgID: 6})
- org = db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org = unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
err := DeleteOrganization(org)
assert.Error(t, err)
assert.True(t, IsErrUserOwnRepos(err))
- user := db.AssertExistsAndLoadBean(t, &User{ID: 5}).(*User)
+ user := unittest.AssertExistsAndLoadBean(t, &User{ID: 5}).(*User)
assert.Error(t, DeleteOrganization(user))
- CheckConsistencyFor(t, &User{}, &Team{})
+ unittest.CheckConsistencyFor(t, &User{}, &Team{})
}
func TestIsOrganizationOwner(t *testing.T) {
@@ -290,7 +290,7 @@ func TestIsOrganizationOwner(t *testing.T) {
test(3, 3, false)
test(6, 5, true)
test(6, 4, false)
- test(db.NonexistentID, db.NonexistentID, false)
+ test(unittest.NonexistentID, unittest.NonexistentID, false)
}
func TestIsOrganizationMember(t *testing.T) {
@@ -305,7 +305,7 @@ func TestIsOrganizationMember(t *testing.T) {
test(3, 4, true)
test(6, 5, true)
test(6, 4, false)
- test(db.NonexistentID, db.NonexistentID, false)
+ test(unittest.NonexistentID, unittest.NonexistentID, false)
}
func TestIsPublicMembership(t *testing.T) {
@@ -320,7 +320,7 @@ func TestIsPublicMembership(t *testing.T) {
test(3, 4, false)
test(6, 5, true)
test(6, 4, false)
- test(db.NonexistentID, db.NonexistentID, false)
+ test(unittest.NonexistentID, unittest.NonexistentID, false)
}
func TestGetOrgsByUserID(t *testing.T) {
@@ -422,7 +422,7 @@ func TestGetOrgUsersByOrgID(t *testing.T) {
orgUsers, err = GetOrgUsersByOrgID(&FindOrgMembersOpts{
ListOptions: db.ListOptions{},
- OrgID: db.NonexistentID,
+ OrgID: unittest.NonexistentID,
PublicOnly: false,
})
assert.NoError(t, err)
@@ -434,29 +434,29 @@ func TestChangeOrgUserStatus(t *testing.T) {
testSuccess := func(orgID, userID int64, public bool) {
assert.NoError(t, ChangeOrgUserStatus(orgID, userID, public))
- orgUser := db.AssertExistsAndLoadBean(t, &OrgUser{OrgID: orgID, UID: userID}).(*OrgUser)
+ orgUser := unittest.AssertExistsAndLoadBean(t, &OrgUser{OrgID: orgID, UID: userID}).(*OrgUser)
assert.Equal(t, public, orgUser.IsPublic)
}
testSuccess(3, 2, false)
testSuccess(3, 2, false)
testSuccess(3, 4, true)
- assert.NoError(t, ChangeOrgUserStatus(db.NonexistentID, db.NonexistentID, true))
+ assert.NoError(t, ChangeOrgUserStatus(unittest.NonexistentID, unittest.NonexistentID, true))
}
func TestAddOrgUser(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
testSuccess := func(orgID, userID int64, isPublic bool) {
- org := db.AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
expectedNumMembers := org.NumMembers
- if !db.BeanExists(t, &OrgUser{OrgID: orgID, UID: userID}) {
+ if !unittest.BeanExists(t, &OrgUser{OrgID: orgID, UID: userID}) {
expectedNumMembers++
}
assert.NoError(t, AddOrgUser(orgID, userID))
ou := &OrgUser{OrgID: orgID, UID: userID}
- db.AssertExistsAndLoadBean(t, ou)
+ unittest.AssertExistsAndLoadBean(t, ou)
assert.Equal(t, isPublic, ou.IsPublic)
- org = db.AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
+ org = unittest.AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
assert.EqualValues(t, expectedNumMembers, org.NumMembers)
}
@@ -468,20 +468,20 @@ func TestAddOrgUser(t *testing.T) {
setting.Service.DefaultOrgMemberVisible = true
testSuccess(6, 3, true)
- CheckConsistencyFor(t, &User{}, &Team{})
+ unittest.CheckConsistencyFor(t, &User{}, &Team{})
}
func TestRemoveOrgUser(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
testSuccess := func(orgID, userID int64) {
- org := db.AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
expectedNumMembers := org.NumMembers
- if db.BeanExists(t, &OrgUser{OrgID: orgID, UID: userID}) {
+ if unittest.BeanExists(t, &OrgUser{OrgID: orgID, UID: userID}) {
expectedNumMembers--
}
assert.NoError(t, RemoveOrgUser(orgID, userID))
- db.AssertNotExistsBean(t, &OrgUser{OrgID: orgID, UID: userID})
- org = db.AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
+ unittest.AssertNotExistsBean(t, &OrgUser{OrgID: orgID, UID: userID})
+ org = unittest.AssertExistsAndLoadBean(t, &User{ID: orgID}).(*User)
assert.EqualValues(t, expectedNumMembers, org.NumMembers)
}
testSuccess(3, 4)
@@ -490,13 +490,13 @@ func TestRemoveOrgUser(t *testing.T) {
err := RemoveOrgUser(7, 5)
assert.Error(t, err)
assert.True(t, IsErrLastOrgOwner(err))
- db.AssertExistsAndLoadBean(t, &OrgUser{OrgID: 7, UID: 5})
- CheckConsistencyFor(t, &User{}, &Team{})
+ unittest.AssertExistsAndLoadBean(t, &OrgUser{OrgID: 7, UID: 5})
+ unittest.CheckConsistencyFor(t, &User{}, &Team{})
}
func TestUser_GetUserTeamIDs(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
testSuccess := func(userID int64, expected []int64) {
teamIDs, err := org.GetUserTeamIDs(userID)
assert.NoError(t, err)
@@ -504,12 +504,12 @@ func TestUser_GetUserTeamIDs(t *testing.T) {
}
testSuccess(2, []int64{1, 2})
testSuccess(4, []int64{2})
- testSuccess(db.NonexistentID, []int64{})
+ testSuccess(unittest.NonexistentID, []int64{})
}
func TestAccessibleReposEnv_CountRepos(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
testSuccess := func(userID, expectedCount int64) {
env, err := org.AccessibleReposEnv(userID)
assert.NoError(t, err)
@@ -523,7 +523,7 @@ func TestAccessibleReposEnv_CountRepos(t *testing.T) {
func TestAccessibleReposEnv_RepoIDs(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
testSuccess := func(userID, _, pageSize int64, expectedRepoIDs []int64) {
env, err := org.AccessibleReposEnv(userID)
assert.NoError(t, err)
@@ -537,7 +537,7 @@ func TestAccessibleReposEnv_RepoIDs(t *testing.T) {
func TestAccessibleReposEnv_Repos(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
testSuccess := func(userID int64, expectedRepoIDs []int64) {
env, err := org.AccessibleReposEnv(userID)
assert.NoError(t, err)
@@ -545,7 +545,7 @@ func TestAccessibleReposEnv_Repos(t *testing.T) {
assert.NoError(t, err)
expectedRepos := make([]*Repository, len(expectedRepoIDs))
for i, repoID := range expectedRepoIDs {
- expectedRepos[i] = db.AssertExistsAndLoadBean(t,
+ expectedRepos[i] = unittest.AssertExistsAndLoadBean(t,
&Repository{ID: repoID}).(*Repository)
}
assert.Equal(t, expectedRepos, repos)
@@ -556,7 +556,7 @@ func TestAccessibleReposEnv_Repos(t *testing.T) {
func TestAccessibleReposEnv_MirrorRepos(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- org := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ org := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
testSuccess := func(userID int64, expectedRepoIDs []int64) {
env, err := org.AccessibleReposEnv(userID)
assert.NoError(t, err)
@@ -564,7 +564,7 @@ func TestAccessibleReposEnv_MirrorRepos(t *testing.T) {
assert.NoError(t, err)
expectedRepos := make([]*Repository, len(expectedRepoIDs))
for i, repoID := range expectedRepoIDs {
- expectedRepos[i] = db.AssertExistsAndLoadBean(t,
+ expectedRepos[i] = unittest.AssertExistsAndLoadBean(t,
&Repository{ID: repoID}).(*Repository)
}
assert.Equal(t, expectedRepos, repos)
@@ -575,8 +575,8 @@ func TestAccessibleReposEnv_MirrorRepos(t *testing.T) {
func TestHasOrgVisibleTypePublic(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- owner := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
- user3 := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ owner := unittest.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ user3 := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
const newOrgName = "test-org-public"
org := &User{
@@ -584,9 +584,9 @@ func TestHasOrgVisibleTypePublic(t *testing.T) {
Visibility: structs.VisibleTypePublic,
}
- db.AssertNotExistsBean(t, &User{Name: org.Name, Type: UserTypeOrganization})
+ unittest.AssertNotExistsBean(t, &User{Name: org.Name, Type: UserTypeOrganization})
assert.NoError(t, CreateOrganization(org, owner))
- org = db.AssertExistsAndLoadBean(t,
+ org = unittest.AssertExistsAndLoadBean(t,
&User{Name: org.Name, Type: UserTypeOrganization}).(*User)
test1 := HasOrgOrUserVisible(org, owner)
test2 := HasOrgOrUserVisible(org, user3)
@@ -598,8 +598,8 @@ func TestHasOrgVisibleTypePublic(t *testing.T) {
func TestHasOrgVisibleTypeLimited(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- owner := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
- user3 := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ owner := unittest.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ user3 := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
const newOrgName = "test-org-limited"
org := &User{
@@ -607,9 +607,9 @@ func TestHasOrgVisibleTypeLimited(t *testing.T) {
Visibility: structs.VisibleTypeLimited,
}
- db.AssertNotExistsBean(t, &User{Name: org.Name, Type: UserTypeOrganization})
+ unittest.AssertNotExistsBean(t, &User{Name: org.Name, Type: UserTypeOrganization})
assert.NoError(t, CreateOrganization(org, owner))
- org = db.AssertExistsAndLoadBean(t,
+ org = unittest.AssertExistsAndLoadBean(t,
&User{Name: org.Name, Type: UserTypeOrganization}).(*User)
test1 := HasOrgOrUserVisible(org, owner)
test2 := HasOrgOrUserVisible(org, user3)
@@ -621,8 +621,8 @@ func TestHasOrgVisibleTypeLimited(t *testing.T) {
func TestHasOrgVisibleTypePrivate(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- owner := db.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
- user3 := db.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
+ owner := unittest.AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
+ user3 := unittest.AssertExistsAndLoadBean(t, &User{ID: 3}).(*User)
const newOrgName = "test-org-private"
org := &User{
@@ -630,9 +630,9 @@ func TestHasOrgVisibleTypePrivate(t *testing.T) {
Visibility: structs.VisibleTypePrivate,
}
- db.AssertNotExistsBean(t, &User{Name: org.Name, Type: UserTypeOrganization})
+ unittest.AssertNotExistsBean(t, &User{Name: org.Name, Type: UserTypeOrganization})
assert.NoError(t, CreateOrganization(org, owner))
- org = db.AssertExistsAndLoadBean(t,
+ org = unittest.AssertExistsAndLoadBean(t,
&User{Name: org.Name, Type: UserTypeOrganization}).(*User)
test1 := HasOrgOrUserVisible(org, owner)
test2 := HasOrgOrUserVisible(org, user3)