mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-23 08:35:34 +02:00
fix: more failing tests
This commit is contained in:
parent
30960026df
commit
1c49bbeff7
@ -54,7 +54,7 @@ func TestXRef_AddCrossReferences(t *testing.T) {
|
|||||||
itarget = testCreateIssue(t, 3, 3, "title4", "content4", false)
|
itarget = testCreateIssue(t, 3, 3, "title4", "content4", false)
|
||||||
|
|
||||||
// Cross-reference to issue #4 by admin
|
// Cross-reference to issue #4 by admin
|
||||||
content = fmt.Sprintf("content5, mentions org3/group/129/repo3#%d", itarget.Index)
|
content = fmt.Sprintf("content5, mentions org3/repo3#%d", itarget.Index)
|
||||||
i = testCreateIssue(t, 2, 1, "title5", content, false)
|
i = testCreateIssue(t, 2, 1, "title5", content, false)
|
||||||
ref = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0})
|
ref = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0})
|
||||||
assert.Equal(t, issues_model.CommentTypeIssueRef, ref.Type)
|
assert.Equal(t, issues_model.CommentTypeIssueRef, ref.Type)
|
||||||
@ -63,7 +63,7 @@ func TestXRef_AddCrossReferences(t *testing.T) {
|
|||||||
assert.Equal(t, references.XRefActionNone, ref.RefAction)
|
assert.Equal(t, references.XRefActionNone, ref.RefAction)
|
||||||
|
|
||||||
// Cross-reference to issue #4 with no permission
|
// Cross-reference to issue #4 with no permission
|
||||||
content = fmt.Sprintf("content6, mentions org3/group/129/repo3#%d", itarget.Index)
|
content = fmt.Sprintf("content6, mentions org3/repo3#%d", itarget.Index)
|
||||||
i = testCreateIssue(t, 4, 5, "title6", content, false)
|
i = testCreateIssue(t, 4, 5, "title6", content, false)
|
||||||
unittest.AssertNotExistsBean(t, &issues_model.Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0})
|
unittest.AssertNotExistsBean(t, &issues_model.Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,6 +65,7 @@ func TestCompareRouterReq(t *testing.T) {
|
|||||||
CompareSeparator: "...",
|
CompareSeparator: "...",
|
||||||
HeadOwner: "teabot",
|
HeadOwner: "teabot",
|
||||||
HeadOriRef: "feature1",
|
HeadOriRef: "feature1",
|
||||||
|
HeadGroupID: -1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,9 @@ package group
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/models/db"
|
||||||
group_model "code.gitea.io/gitea/models/group"
|
group_model "code.gitea.io/gitea/models/group"
|
||||||
|
organization_model "code.gitea.io/gitea/models/organization"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
"code.gitea.io/gitea/models/unittest"
|
"code.gitea.io/gitea/models/unittest"
|
||||||
user_model "code.gitea.io/gitea/models/user"
|
user_model "code.gitea.io/gitea/models/user"
|
||||||
@ -21,12 +23,43 @@ func TestMain(m *testing.M) {
|
|||||||
unittest.MainTest(m)
|
unittest.MainTest(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getOrCreateOrgWithGroups(t *testing.T) *user_model.User {
|
||||||
|
e := db.GetEngine(t.Context())
|
||||||
|
norg := &user_model.User{
|
||||||
|
LowerName: "org-with-groups",
|
||||||
|
FullName: "Org With Groups",
|
||||||
|
Name: "Org-With-Groups",
|
||||||
|
Type: user_model.UserTypeOrganization,
|
||||||
|
}
|
||||||
|
|
||||||
|
hasOrgWithGroups, err := e.Exist(&user_model.User{
|
||||||
|
LowerName: norg.LowerName,
|
||||||
|
Type: norg.Type,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
if !hasOrgWithGroups {
|
||||||
|
ownerBean := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||||
|
ID: 2,
|
||||||
|
})
|
||||||
|
assert.NoError(t, organization_model.CreateOrganization(t.Context(), organization_model.OrgFromUser(norg), ownerBean))
|
||||||
|
_, err = e.Table(&group_model.Group{}).Update(&group_model.Group{
|
||||||
|
OwnerName: norg.Name,
|
||||||
|
OwnerID: norg.ID,
|
||||||
|
})
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
norg = unittest.AssertExistsAndLoadBean(t, norg)
|
||||||
|
return norg
|
||||||
|
}
|
||||||
|
|
||||||
func TestNewGroup(t *testing.T) {
|
func TestNewGroup(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
orgWithGroups := getOrCreateOrgWithGroups(t)
|
||||||
|
|
||||||
const groupName = "group x"
|
const groupName = "group x"
|
||||||
group := &group_model.Group{
|
group := &group_model.Group{
|
||||||
Name: groupName,
|
Name: groupName,
|
||||||
OwnerID: 3,
|
OwnerID: orgWithGroups.ID,
|
||||||
}
|
}
|
||||||
assert.NoError(t, NewGroup(t.Context(), group))
|
assert.NoError(t, NewGroup(t.Context(), group))
|
||||||
unittest.AssertExistsAndLoadBean(t, &group_model.Group{Name: groupName})
|
unittest.AssertExistsAndLoadBean(t, &group_model.Group{Name: groupName})
|
||||||
@ -34,13 +67,14 @@ func TestNewGroup(t *testing.T) {
|
|||||||
|
|
||||||
func TestMoveGroup(t *testing.T) {
|
func TestMoveGroup(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
|
orgWithGroups := getOrCreateOrgWithGroups(t)
|
||||||
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||||
ID: 28,
|
ID: 2,
|
||||||
})
|
})
|
||||||
testfn := func(gid int64) {
|
testfn := func(gid int64) {
|
||||||
cond := &group_model.FindGroupsOptions{
|
cond := &group_model.FindGroupsOptions{
|
||||||
ParentGroupID: 123,
|
ParentGroupID: 123,
|
||||||
OwnerID: 3,
|
OwnerID: orgWithGroups.ID,
|
||||||
}
|
}
|
||||||
origCount := unittest.GetCount(t, new(group_model.Group), cond.ToConds())
|
origCount := unittest.GetCount(t, new(group_model.Group), cond.ToConds())
|
||||||
|
|
||||||
@ -60,7 +94,7 @@ func TestMoveGroup(t *testing.T) {
|
|||||||
func TestMoveRepo(t *testing.T) {
|
func TestMoveRepo(t *testing.T) {
|
||||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||||
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
doer := unittest.AssertExistsAndLoadBean(t, &user_model.User{
|
||||||
ID: 28,
|
ID: 2,
|
||||||
})
|
})
|
||||||
cond := repo_model.SearchRepositoryCondition(repo_model.SearchRepoOptions{
|
cond := repo_model.SearchRepositoryCondition(repo_model.SearchRepoOptions{
|
||||||
GroupID: 123,
|
GroupID: 123,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user