Skip to content

Commit e38a773

Browse files
committed
fix lints, tests
1 parent 000c930 commit e38a773

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

models/fixtures/login_source.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
-
2-
id: 1
3-
type: 6
4-
is_active: true
5-
cfg: "{\"Source\":{\"A\":\"string\",\"B\":1}}"
1+
[]

models/fixtures/user.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,17 +1559,17 @@
15591559

15601560
-
15611561
id: 43
1562-
lower_name: nonlocaluser1
1563-
name: nonlocaluser1
1564-
full_name: User One
1565-
email: nonlocaluser1@example.com
1562+
lower_name: user43
1563+
name: user43
1564+
full_name: Non-Local User One
1565+
email: user43@example.com
15661566
keep_email_private: false
15671567
email_notifications_preference: enabled
15681568
passwd: ZogKvWdyEx:password
15691569
passwd_hash_algo: dummy
15701570
must_change_password: false
15711571
login_source: 1
1572-
login_name: nonlocaluser1
1572+
login_name: user43
15731573
type: 0
15741574
salt: ZogKvWdyEx
15751575
max_repo_creation: -1
@@ -1581,7 +1581,7 @@
15811581
allow_create_organization: true
15821582
prohibit_login: false
15831583
avatar: ""
1584-
avatar_email: nonlocaluser1@example.com
1584+
avatar_email: user43@example.com
15851585
use_custom_avatar: true
15861586
num_followers: 0
15871587
num_following: 0
@@ -1596,17 +1596,17 @@
15961596

15971597
-
15981598
id: 44
1599-
lower_name: nonlocaluser2
1600-
name: nonlocaluser2
1601-
full_name: User Two
1602-
email: nonlocaluser2@example.com
1599+
lower_name: user44
1600+
name: user44
1601+
full_name: Non-Local User Two
1602+
email: user44@example.com
16031603
keep_email_private: false
16041604
email_notifications_preference: enabled
16051605
passwd: ZogKvWdyEx:password
16061606
passwd_hash_algo: dummy
16071607
must_change_password: false
16081608
login_source: 1
1609-
login_name: nonlocaluser2
1609+
login_name: user44
16101610
type: 0
16111611
salt: ZogKvWdyEx
16121612
max_repo_creation: -1
@@ -1618,7 +1618,7 @@
16181618
allow_create_organization: true
16191619
prohibit_login: false
16201620
avatar: ""
1621-
avatar_email: nonlocaluser2@example.com
1621+
avatar_email: user44@example.com
16221622
use_custom_avatar: true
16231623
num_followers: 0
16241624
num_following: 0
@@ -1630,5 +1630,3 @@
16301630
repo_admin_change_team_access: false
16311631
theme: ""
16321632
keep_activity_private: false
1633-
1634-

models/user/user_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ func TestSearchUsers(t *testing.T) {
155155
}
156156

157157
testUserSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}},
158-
[]int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32, 34, 37, 38, 39, 40})
158+
[]int64{1, 2, 4, 5, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32, 34, 37, 38, 39, 40, 43, 44})
159159

160160
testUserSuccess(user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 1}, IsActive: optional.Some(false)},
161161
[]int64{9})
162162

163163
testUserSuccess(user_model.SearchUserOptions{OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: optional.Some(true)},
164-
[]int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32, 34, 37, 38, 39, 40})
164+
[]int64{1, 2, 4, 5, 8, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 24, 27, 28, 29, 30, 32, 34, 37, 38, 39, 40, 43, 44})
165165

166166
testUserSuccess(user_model.SearchUserOptions{Keyword: "user1", OrderBy: "id ASC", ListOptions: db.ListOptions{Page: 1}, IsActive: optional.Some(true)},
167167
[]int64{1, 10, 11, 12, 13, 14, 15, 16, 18})
@@ -171,7 +171,7 @@ func TestSearchUsers(t *testing.T) {
171171
[]int64{1, 10, 11, 12, 13, 14, 15, 16, 18})
172172

173173
testUserSuccess(user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 1}, IsAdmin: optional.Some(true)},
174-
[]int64{1})
174+
[]int64{1, 43})
175175

176176
testUserSuccess(user_model.SearchUserOptions{ListOptions: db.ListOptions{Page: 1}, IsRestricted: optional.Some(true)},
177177
[]int64{29})

services/user/update_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ func TestUpdateUser(t *testing.T) {
1919
assert.NoError(t, unittest.PrepareTestDatabase())
2020

2121
admin := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
22+
nonLocalAdmin := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 43})
23+
24+
// Need to make the nonlocal admin not an admin for the following checks to make sense
25+
assert.NoError(t, UpdateUser(t.Context(), nonLocalAdmin, &UpdateOptions{
26+
IsAdmin: UpdateOptionFieldFromValue(false),
27+
}))
2228

2329
assert.Error(t, UpdateUser(t.Context(), admin, &UpdateOptions{
2430
IsAdmin: UpdateOptionFieldFromValue(false),

tests/integration/api_nodeinfo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestNodeinfo(t *testing.T) {
2929
DecodeJSON(t, resp, &nodeinfo)
3030
assert.True(t, nodeinfo.OpenRegistrations)
3131
assert.Equal(t, "gitea", nodeinfo.Software.Name)
32-
assert.Equal(t, 29, nodeinfo.Usage.Users.Total)
32+
assert.Equal(t, 31, nodeinfo.Usage.Users.Total)
3333
assert.Equal(t, 22, nodeinfo.Usage.LocalPosts)
3434
assert.Equal(t, 3, nodeinfo.Usage.LocalComments)
3535
}

0 commit comments

Comments
 (0)