Skip to content

Commit 06bcdfe

Browse files
GiteaBotKN4CK3R
andauthored
Remove unused code (go-gitea#25734) (go-gitea#25788)
Backport go-gitea#25734 by @KN4CK3R The method is only used in the test. Found it because I changed the fixtures and had a hard time fixing this test. My revenge is deleting it. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
1 parent a5a3c81 commit 06bcdfe

File tree

2 files changed

+0
-57
lines changed

2 files changed

+0
-57
lines changed

models/organization/org.go

-21
Original file line numberDiff line numberDiff line change
@@ -532,27 +532,6 @@ func GetOrgsCanCreateRepoByUserID(userID int64) ([]*Organization, error) {
532532
Find(&orgs)
533533
}
534534

535-
// GetOrgUsersByUserID returns all organization-user relations by user ID.
536-
func GetOrgUsersByUserID(uid int64, opts *SearchOrganizationsOptions) ([]*OrgUser, error) {
537-
ous := make([]*OrgUser, 0, 10)
538-
sess := db.GetEngine(db.DefaultContext).
539-
Join("LEFT", "`user`", "`org_user`.org_id=`user`.id").
540-
Where("`org_user`.uid=?", uid)
541-
if !opts.All {
542-
// Only show public organizations
543-
sess.And("is_public=?", true)
544-
}
545-
546-
if opts.PageSize != 0 {
547-
sess = db.SetSessionPagination(sess, opts)
548-
}
549-
550-
err := sess.
551-
Asc("`user`.name").
552-
Find(&ous)
553-
return ous, err
554-
}
555-
556535
// GetOrgUsersByOrgID returns all organization-user relations by organization ID.
557536
func GetOrgUsersByOrgID(ctx context.Context, opts *FindOrgMembersOpts) ([]*OrgUser, error) {
558537
sess := db.GetEngine(ctx).Where("org_id=?", opts.OrgID)

models/organization/org_test.go

-36
Original file line numberDiff line numberDiff line change
@@ -207,42 +207,6 @@ func TestFindOrgs(t *testing.T) {
207207
assert.EqualValues(t, 1, total)
208208
}
209209

210-
func TestGetOrgUsersByUserID(t *testing.T) {
211-
assert.NoError(t, unittest.PrepareTestDatabase())
212-
213-
orgUsers, err := organization.GetOrgUsersByUserID(5, &organization.SearchOrganizationsOptions{All: true})
214-
assert.NoError(t, err)
215-
if assert.Len(t, orgUsers, 3) {
216-
assert.Equal(t, organization.OrgUser{
217-
ID: orgUsers[0].ID,
218-
OrgID: 23,
219-
UID: 5,
220-
IsPublic: false,
221-
}, *orgUsers[0])
222-
assert.Equal(t, organization.OrgUser{
223-
ID: orgUsers[1].ID,
224-
OrgID: 6,
225-
UID: 5,
226-
IsPublic: true,
227-
}, *orgUsers[1])
228-
assert.Equal(t, organization.OrgUser{
229-
ID: orgUsers[2].ID,
230-
OrgID: 7,
231-
UID: 5,
232-
IsPublic: false,
233-
}, *orgUsers[2])
234-
}
235-
236-
publicOrgUsers, err := organization.GetOrgUsersByUserID(5, &organization.SearchOrganizationsOptions{All: false})
237-
assert.NoError(t, err)
238-
assert.Len(t, publicOrgUsers, 1)
239-
assert.Equal(t, *orgUsers[1], *publicOrgUsers[0])
240-
241-
orgUsers, err = organization.GetOrgUsersByUserID(1, &organization.SearchOrganizationsOptions{All: true})
242-
assert.NoError(t, err)
243-
assert.Len(t, orgUsers, 0)
244-
}
245-
246210
func TestGetOrgUsersByOrgID(t *testing.T) {
247211
assert.NoError(t, unittest.PrepareTestDatabase())
248212

0 commit comments

Comments
 (0)