Skip to content

Commit da50be7

Browse files
lng2020CaiCandong
andauthored
Replace 'userxx' with 'orgxx' in all test files when the user type is org (#27052)
Currently 'userxx' and 'orgxx' are both used as username in test files when the user type is org, which is confusing. This PR replaces all 'userxx' with 'orgxx' when the user type is org(`user.type==1`). Some non-trivial changes 1. Rename `user3` dir to `org3` in `tests/git-repositories-meta` 2. Change `end` in `issue reference` because 'org3' is one char shorter than 'user3' ![ksnip_20230913-112819](https://github.com/go-gitea/gitea/assets/70063547/442988c5-4cf4-49b8-aa01-4dd6bf0ca954) 3. Change the search result number of `user/repo2` because `user3/repo21` can't be searched now ![ksnip_20230913-112931](https://github.com/go-gitea/gitea/assets/70063547/d9ebeba4-479f-4110-9a85-825efbc981fd) 4. Change the first org name getting from API because the result is ordered by alphabet asc and now `org 17` is before `org25` ![JW8U7NIO(J$H _YCRB36H)T](https://github.com/go-gitea/gitea/assets/70063547/f55a685c-cf24-40e5-a87f-3a2327319548) ![)KFD411O4I8RB5ZOH7E0 Z3](https://github.com/go-gitea/gitea/assets/70063547/a0dc3299-249c-46f6-91cb-d15d4ee88dd5) Other modifications are just find all and replace all. Unit tests with SQLite are all passed. --------- Co-authored-by: caicandong <[email protected]>
1 parent d0318c4 commit da50be7

File tree

91 files changed

+280
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+280
-280
lines changed

models/fixtures/email_address.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@
7373
-
7474
id: 10
7575
uid: 3
76-
email: user3@example.com
77-
lower_email: user3@example.com
76+
email: org3@example.com
77+
lower_email: org3@example.com
7878
is_activated: true
7979
is_primary: true
8080

@@ -97,16 +97,16 @@
9797
-
9898
id: 13
9999
uid: 6
100-
email: user6@example.com
101-
lower_email: user6@example.com
100+
email: org6@example.com
101+
lower_email: org6@example.com
102102
is_activated: true
103103
is_primary: true
104104

105105
-
106106
id: 14
107107
uid: 7
108-
email: user7@example.com
109-
lower_email: user7@example.com
108+
email: org7@example.com
109+
lower_email: org7@example.com
110110
is_activated: true
111111
is_primary: true
112112

@@ -153,8 +153,8 @@
153153
-
154154
id: 20
155155
uid: 17
156-
email: user17@example.com
157-
lower_email: user17@example.com
156+
email: org17@example.com
157+
lower_email: org17@example.com
158158
is_activated: true
159159
is_primary: true
160160

@@ -169,8 +169,8 @@
169169
-
170170
id: 22
171171
uid: 19
172-
email: user19@example.com
173-
lower_email: user19@example.com
172+
email: org19@example.com
173+
lower_email: org19@example.com
174174
is_activated: true
175175
is_primary: true
176176

models/fixtures/repository.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
-
6565
id: 3
6666
owner_id: 3
67-
owner_name: user3
67+
owner_name: org3
6868
lower_name: repo3
6969
name: repo3
7070
default_branch: master
@@ -126,7 +126,7 @@
126126
-
127127
id: 5
128128
owner_id: 3
129-
owner_name: user3
129+
owner_name: org3
130130
lower_name: repo5
131131
name: repo5
132132
num_watches: 0
@@ -671,7 +671,7 @@
671671
-
672672
id: 23
673673
owner_id: 17
674-
owner_name: user17
674+
owner_name: org17
675675
lower_name: big_test_public_4
676676
name: big_test_public_4
677677
num_watches: 0
@@ -701,7 +701,7 @@
701701
-
702702
id: 24
703703
owner_id: 17
704-
owner_name: user17
704+
owner_name: org17
705705
lower_name: big_test_private_4
706706
name: big_test_private_4
707707
num_watches: 0
@@ -791,7 +791,7 @@
791791
-
792792
id: 27
793793
owner_id: 19
794-
owner_name: user19
794+
owner_name: org19
795795
lower_name: big_test_public_mirror_6
796796
name: big_test_public_mirror_6
797797
num_watches: 0
@@ -821,7 +821,7 @@
821821
-
822822
id: 28
823823
owner_id: 19
824-
owner_name: user19
824+
owner_name: org19
825825
lower_name: big_test_private_mirror_6
826826
name: big_test_private_mirror_6
827827
num_watches: 0
@@ -942,7 +942,7 @@
942942
-
943943
id: 32 # org public repo
944944
owner_id: 3
945-
owner_name: user3
945+
owner_name: org3
946946
lower_name: repo21
947947
name: repo21
948948
num_watches: 0

models/fixtures/review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@
129129
type: 1
130130
reviewer_id: 6
131131
issue_id: 11
132-
content: "singular review from user6 and final review for this pr"
132+
content: "singular review from org6 and final review for this pr"
133133
updated_unix: 946684831
134134
created_unix: 946684831

models/fixtures/user.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@
7676

7777
-
7878
id: 3
79-
lower_name: user3
80-
name: user3
79+
lower_name: org3
80+
name: org3
8181
full_name: ' <<<< >> >> > >> > >>> >> '
82-
email: user3@example.com
82+
email: org3@example.com
8383
keep_email_private: false
8484
email_notifications_preference: onmention
8585
passwd: ZogKvWdyEx:password
8686
passwd_hash_algo: dummy
8787
must_change_password: false
8888
login_source: 0
89-
login_name: user3
89+
login_name: org3
9090
type: 1
9191
salt: ZogKvWdyEx
9292
max_repo_creation: -1
@@ -98,7 +98,7 @@
9898
allow_create_organization: true
9999
prohibit_login: false
100100
avatar: avatar3
101-
avatar_email: user3@example.com
101+
avatar_email: org3@example.com
102102
use_custom_avatar: false
103103
num_followers: 0
104104
num_following: 0
@@ -187,17 +187,17 @@
187187

188188
-
189189
id: 6
190-
lower_name: user6
191-
name: user6
192-
full_name: User Six
193-
email: user6@example.com
190+
lower_name: org6
191+
name: org6
192+
full_name: Org Six
193+
email: org6@example.com
194194
keep_email_private: false
195195
email_notifications_preference: enabled
196196
passwd: ZogKvWdyEx:password
197197
passwd_hash_algo: dummy
198198
must_change_password: false
199199
login_source: 0
200-
login_name: user6
200+
login_name: org6
201201
type: 1
202202
salt: ZogKvWdyEx
203203
max_repo_creation: -1
@@ -209,7 +209,7 @@
209209
allow_create_organization: true
210210
prohibit_login: false
211211
avatar: avatar6
212-
avatar_email: user6@example.com
212+
avatar_email: org6@example.com
213213
use_custom_avatar: false
214214
num_followers: 0
215215
num_following: 0
@@ -224,17 +224,17 @@
224224

225225
-
226226
id: 7
227-
lower_name: user7
228-
name: user7
229-
full_name: User Seven
230-
email: user7@example.com
227+
lower_name: org7
228+
name: org7
229+
full_name: Org Seven
230+
email: org7@example.com
231231
keep_email_private: false
232232
email_notifications_preference: disabled
233233
passwd: ZogKvWdyEx:password
234234
passwd_hash_algo: dummy
235235
must_change_password: false
236236
login_source: 0
237-
login_name: user7
237+
login_name: org7
238238
type: 1
239239
salt: ZogKvWdyEx
240240
max_repo_creation: -1
@@ -246,7 +246,7 @@
246246
allow_create_organization: true
247247
prohibit_login: false
248248
avatar: avatar7
249-
avatar_email: user7@example.com
249+
avatar_email: org7@example.com
250250
use_custom_avatar: false
251251
num_followers: 0
252252
num_following: 0
@@ -594,17 +594,17 @@
594594

595595
-
596596
id: 17
597-
lower_name: user17
598-
name: user17
599-
full_name: User 17
600-
email: user17@example.com
597+
lower_name: org17
598+
name: org17
599+
full_name: org 17
600+
email: org17@example.com
601601
keep_email_private: false
602602
email_notifications_preference: enabled
603603
passwd: ZogKvWdyEx:password
604604
passwd_hash_algo: dummy
605605
must_change_password: false
606606
login_source: 0
607-
login_name: user17
607+
login_name: org17
608608
type: 1
609609
salt: ZogKvWdyEx
610610
max_repo_creation: -1
@@ -616,7 +616,7 @@
616616
allow_create_organization: true
617617
prohibit_login: false
618618
avatar: avatar17
619-
avatar_email: user17@example.com
619+
avatar_email: org17@example.com
620620
use_custom_avatar: false
621621
num_followers: 0
622622
num_following: 0
@@ -668,17 +668,17 @@
668668

669669
-
670670
id: 19
671-
lower_name: user19
672-
name: user19
673-
full_name: User 19
674-
email: user19@example.com
671+
lower_name: org19
672+
name: org19
673+
full_name: Org 19
674+
email: org19@example.com
675675
keep_email_private: false
676676
email_notifications_preference: enabled
677677
passwd: ZogKvWdyEx:password
678678
passwd_hash_algo: dummy
679679
must_change_password: false
680680
login_source: 0
681-
login_name: user19
681+
login_name: org19
682682
type: 1
683683
salt: ZogKvWdyEx
684684
max_repo_creation: -1
@@ -690,7 +690,7 @@
690690
allow_create_organization: true
691691
prohibit_login: false
692692
avatar: avatar19
693-
avatar_email: user19@example.com
693+
avatar_email: org19@example.com
694694
use_custom_avatar: false
695695
num_followers: 0
696696
num_following: 0

models/issues/assignees_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ func TestUpdateAssignee(t *testing.T) {
2727
_, _, err = issues_model.ToggleIssueAssignee(db.DefaultContext, issue, &user_model.User{ID: 1}, user2.ID)
2828
assert.NoError(t, err)
2929

30-
user3, err := user_model.GetUserByID(db.DefaultContext, 3)
30+
org3, err := user_model.GetUserByID(db.DefaultContext, 3)
3131
assert.NoError(t, err)
32-
_, _, err = issues_model.ToggleIssueAssignee(db.DefaultContext, issue, &user_model.User{ID: 1}, user3.ID)
32+
_, _, err = issues_model.ToggleIssueAssignee(db.DefaultContext, issue, &user_model.User{ID: 1}, org3.ID)
3333
assert.NoError(t, err)
3434

3535
user1, err := user_model.GetUserByID(db.DefaultContext, 1) // This user is already assigned (see the definition in fixtures), so running UpdateAssignee should unassign him
@@ -47,7 +47,7 @@ func TestUpdateAssignee(t *testing.T) {
4747
assert.NoError(t, err)
4848

4949
var expectedAssignees []*user_model.User
50-
expectedAssignees = append(expectedAssignees, user2, user3)
50+
expectedAssignees = append(expectedAssignees, user2, org3)
5151

5252
for in, assignee := range issue.Assignees {
5353
assert.Equal(t, assignee.ID, expectedAssignees[in].ID)

models/issues/issue_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,11 @@ func TestIssue_ResolveMentions(t *testing.T) {
430430
// Public repo, doer
431431
testSuccess("user2", "repo1", "user1", []string{"user1"}, []int64{})
432432
// Private repo, team member
433-
testSuccess("user17", "big_test_private_4", "user20", []string{"user2"}, []int64{2})
433+
testSuccess("org17", "big_test_private_4", "user20", []string{"user2"}, []int64{2})
434434
// Private repo, not a team member
435-
testSuccess("user17", "big_test_private_4", "user20", []string{"user5"}, []int64{})
435+
testSuccess("org17", "big_test_private_4", "user20", []string{"user5"}, []int64{})
436436
// Private repo, whole team
437-
testSuccess("user17", "big_test_private_4", "user15", []string{"user17/owners"}, []int64{18})
437+
testSuccess("org17", "big_test_private_4", "user15", []string{"org17/owners"}, []int64{18})
438438
}
439439

440440
func TestResourceIndex(t *testing.T) {

models/issues/issue_xref_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestXRef_AddCrossReferences(t *testing.T) {
5454
itarget = testCreateIssue(t, 3, 3, "title4", "content4", false)
5555

5656
// Cross-reference to issue #4 by admin
57-
content = fmt.Sprintf("content5, mentions user3/repo3#%d", itarget.Index)
57+
content = fmt.Sprintf("content5, mentions org3/repo3#%d", itarget.Index)
5858
i = testCreateIssue(t, 2, 1, "title5", content, false)
5959
ref = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0})
6060
assert.Equal(t, issues_model.CommentTypeIssueRef, ref.Type)
@@ -63,7 +63,7 @@ func TestXRef_AddCrossReferences(t *testing.T) {
6363
assert.Equal(t, references.XRefActionNone, ref.RefAction)
6464

6565
// Cross-reference to issue #4 with no permission
66-
content = fmt.Sprintf("content6, mentions user3/repo3#%d", itarget.Index)
66+
content = fmt.Sprintf("content6, mentions org3/repo3#%d", itarget.Index)
6767
i = testCreateIssue(t, 4, 5, "title6", content, false)
6868
unittest.AssertNotExistsBean(t, &issues_model.Comment{IssueID: itarget.ID, RefIssueID: i.ID, RefCommentID: 0})
6969
}

models/issues/pull_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ func TestParseCodeOwnersLine(t *testing.T) {
317317
{Line: "# comment", Tokens: []string{}},
318318
{Line: "!.* @user1 @org1/team1", Tokens: []string{"!.*", "@user1", "@org1/team1"}},
319319
{Line: `.*\\.js @user2 #comment`, Tokens: []string{`.*\.js`, "@user2"}},
320-
{Line: `docs/(aws|google|azure)/[^/]*\\.(md|txt) @user3 @org2/team2`, Tokens: []string{`docs/(aws|google|azure)/[^/]*\.(md|txt)`, "@user3", "@org2/team2"}},
321-
{Line: `\#path @user3`, Tokens: []string{`#path`, "@user3"}},
322-
{Line: `path\ with\ spaces/ @user3`, Tokens: []string{`path with spaces/`, "@user3"}},
320+
{Line: `docs/(aws|google|azure)/[^/]*\\.(md|txt) @org3 @org2/team2`, Tokens: []string{`docs/(aws|google|azure)/[^/]*\.(md|txt)`, "@org3", "@org2/team2"}},
321+
{Line: `\#path @org3`, Tokens: []string{`#path`, "@org3"}},
322+
{Line: `path\ with\ spaces/ @org3`, Tokens: []string{`path with spaces/`, "@org3"}},
323323
}
324324

325325
for _, g := range given {
@@ -335,7 +335,7 @@ func TestGetApprovers(t *testing.T) {
335335
// to assert that there are no duplicated approvers.
336336
setting.Repository.PullRequest.DefaultMergeMessageOfficialApproversOnly = false
337337
approvers := pr.GetApprovers()
338-
expected := "Reviewed-by: User Five <[email protected]>\nReviewed-by: User Six <user6@example.com>\n"
338+
expected := "Reviewed-by: User Five <[email protected]>\nReviewed-by: Org Six <org6@example.com>\n"
339339
assert.EqualValues(t, expected, approvers)
340340
}
341341

models/issues/reaction_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestIssueReactionCount(t *testing.T) {
8383

8484
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
8585
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
86-
user3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3})
86+
org3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3})
8787
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})
8888
ghost := user_model.NewGhostUser()
8989

@@ -92,8 +92,8 @@ func TestIssueReactionCount(t *testing.T) {
9292

9393
addReaction(t, user1.ID, issueID, 0, "heart")
9494
addReaction(t, user2.ID, issueID, 0, "heart")
95-
addReaction(t, user3.ID, issueID, 0, "heart")
96-
addReaction(t, user3.ID, issueID, 0, "+1")
95+
addReaction(t, org3.ID, issueID, 0, "heart")
96+
addReaction(t, org3.ID, issueID, 0, "+1")
9797
addReaction(t, user4.ID, issueID, 0, "+1")
9898
addReaction(t, user4.ID, issueID, 0, "heart")
9999
addReaction(t, ghost.ID, issueID, 0, "-1")
@@ -136,15 +136,15 @@ func TestIssueCommentDeleteReaction(t *testing.T) {
136136

137137
user1 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
138138
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2})
139-
user3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3})
139+
org3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3})
140140
user4 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 4})
141141

142142
var issue1ID int64 = 1
143143
var comment1ID int64 = 1
144144

145145
addReaction(t, user1.ID, issue1ID, comment1ID, "heart")
146146
addReaction(t, user2.ID, issue1ID, comment1ID, "heart")
147-
addReaction(t, user3.ID, issue1ID, comment1ID, "heart")
147+
addReaction(t, org3.ID, issue1ID, comment1ID, "heart")
148148
addReaction(t, user4.ID, issue1ID, comment1ID, "+1")
149149

150150
reactionsList, _, err := issues_model.FindReactions(db.DefaultContext, issues_model.FindReactionsOptions{

0 commit comments

Comments
 (0)