From 5740f2fc830356acb7929a02fe304008b94a0ca5 Mon Sep 17 00:00:00 2001
From: Earl Warren <contact@earl-warren.org>
Date: Mon, 18 Sep 2023 16:20:47 +0200
Subject: [PATCH] [MODERATION] cope with shared fixtures

* There is one more issue in the fixtures and this breaks some tests
* The users in the shared fixtures were renamed for clarity and that
  breaks some tests

(cherry picked from commit 707a4edbdf67d0eb168d7bb430cf85dd8cd63c52)

Conflicts:
	modules/indexer/issues/indexer_test.go
	https://codeberg.org/forgejo/forgejo/pulls/1508
(cherry picked from commit 82cc044366c749df80ffad44eed2988b8e64211e)
(cherry picked from commit 2776aec7e85850f1d7f01a090a72491550fb9d29)
(cherry picked from commit 1fbde36dc784b5b2cc6193f02ff0d436b0f2a629)
(cherry picked from commit 1293db3c4e5df218501f5add9f9d41101ffcb8aa)
(cherry picked from commit 6476802175bac3ef78dd8f24ff6bebc16f398a78)
---
 models/issues/issue_test.go            |  2 +-
 modules/indexer/issues/indexer_test.go | 12 ++++++------
 tests/integration/api_block_test.go    |  4 ++--
 tests/integration/api_issue_test.go    |  2 +-
 tests/integration/issue_test.go        | 10 +++++-----
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/models/issues/issue_test.go b/models/issues/issue_test.go
index 9e9733e8f6..2eb8a33adc 100644
--- a/models/issues/issue_test.go
+++ b/models/issues/issue_test.go
@@ -411,7 +411,7 @@ func TestCountIssues(t *testing.T) {
 	assert.NoError(t, unittest.PrepareTestDatabase())
 	count, err := issues_model.CountIssues(db.DefaultContext, &issues_model.IssuesOptions{})
 	assert.NoError(t, err)
-	assert.EqualValues(t, 20, count)
+	assert.EqualValues(t, 21, count)
 }
 
 func TestIssueLoadAttributes(t *testing.T) {
diff --git a/modules/indexer/issues/indexer_test.go b/modules/indexer/issues/indexer_test.go
index da4fc9b878..f026df6e64 100644
--- a/modules/indexer/issues/indexer_test.go
+++ b/modules/indexer/issues/indexer_test.go
@@ -212,7 +212,7 @@ func searchIssueIsPull(t *testing.T) {
 			SearchOptions{
 				IsPull: util.OptionalBoolFalse,
 			},
-			[]int64{17, 16, 15, 14, 13, 6, 5, 18, 10, 7, 4, 1},
+			[]int64{17, 16, 15, 14, 13, 6, 5, 21, 18, 10, 7, 4, 1},
 		},
 		{
 			SearchOptions{
@@ -239,7 +239,7 @@ func searchIssueIsClosed(t *testing.T) {
 			SearchOptions{
 				IsClosed: util.OptionalBoolFalse,
 			},
-			[]int64{17, 16, 15, 14, 13, 12, 11, 20, 6, 19, 18, 10, 7, 9, 8, 3, 2, 1},
+			[]int64{17, 16, 15, 14, 13, 12, 11, 20, 6, 21, 19, 18, 10, 7, 9, 8, 3, 2, 1},
 		},
 		{
 			SearchOptions{
@@ -305,7 +305,7 @@ func searchIssueByLabelID(t *testing.T) {
 			SearchOptions{
 				ExcludedLabelIDs: []int64{1},
 			},
-			[]int64{17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3},
+			[]int64{17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 21, 19, 18, 10, 7, 4, 9, 8, 3},
 		},
 	}
 	for _, test := range tests {
@@ -329,7 +329,7 @@ func searchIssueByTime(t *testing.T) {
 			SearchOptions{
 				UpdatedAfterUnix: int64Pointer(0),
 			},
-			[]int64{17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2, 1},
+			[]int64{17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 21, 19, 18, 10, 7, 4, 9, 8, 3, 2, 1},
 		},
 	}
 	for _, test := range tests {
@@ -350,7 +350,7 @@ func searchIssueWithOrder(t *testing.T) {
 			SearchOptions{
 				SortBy: internal.SortByCreatedAsc,
 			},
-			[]int64{1, 2, 3, 8, 9, 4, 7, 10, 18, 19, 5, 6, 20, 11, 12, 13, 14, 15, 16, 17},
+			[]int64{1, 2, 3, 8, 9, 4, 7, 10, 18, 19, 21, 5, 6, 20, 11, 12, 13, 14, 15, 16, 17},
 		},
 	}
 	for _, test := range tests {
@@ -411,7 +411,7 @@ func searchIssueWithPaginator(t *testing.T) {
 				},
 			},
 			[]int64{17, 16, 15, 14, 13},
-			20,
+			21,
 		},
 	}
 	for _, test := range tests {
diff --git a/tests/integration/api_block_test.go b/tests/integration/api_block_test.go
index 48ee51bffa..cbdcb29cf3 100644
--- a/tests/integration/api_block_test.go
+++ b/tests/integration/api_block_test.go
@@ -84,7 +84,7 @@ func TestAPIOrgBlock(t *testing.T) {
 	defer tests.PrepareTestEnv(t)()
 
 	user := "user5"
-	org := "user6"
+	org := "org6"
 	session := loginUser(t, user)
 	token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteOrganization)
 
@@ -163,7 +163,7 @@ func TestAPIOrgBlock(t *testing.T) {
 	t.Run("Not as owner", func(t *testing.T) {
 		defer tests.PrintCurrentTest(t)()
 
-		org := "user3"
+		org := "org3"
 		user := "user4" // Part of org team with write perms.
 
 		session := loginUser(t, user)
diff --git a/tests/integration/api_issue_test.go b/tests/integration/api_issue_test.go
index 248c59ac86..ed16057088 100644
--- a/tests/integration/api_issue_test.go
+++ b/tests/integration/api_issue_test.go
@@ -411,7 +411,7 @@ func TestAPISearchIssues(t *testing.T) {
 	resp = MakeRequest(t, req, http.StatusOK)
 	DecodeJSON(t, resp, &apiIssues)
 	assert.EqualValues(t, "21", resp.Header().Get("X-Total-Count"))
-	assert.Len(t, apiIssues, 21)
+	assert.Len(t, apiIssues, 20)
 
 	query.Add("limit", "10")
 	link.RawQuery = query.Encode()
diff --git a/tests/integration/issue_test.go b/tests/integration/issue_test.go
index ac06b487db..b07bcadc26 100644
--- a/tests/integration/issue_test.go
+++ b/tests/integration/issue_test.go
@@ -357,7 +357,7 @@ func TestSearchIssues(t *testing.T) {
 
 	session := loginUser(t, "user2")
 
-	expectedIssueCount := 18 // from the fixtures
+	expectedIssueCount := 19 // from the fixtures
 	if expectedIssueCount > setting.UI.IssuePagingNum {
 		expectedIssueCount = setting.UI.IssuePagingNum
 	}
@@ -378,7 +378,7 @@ func TestSearchIssues(t *testing.T) {
 	req = NewRequest(t, "GET", link.String())
 	resp = session.MakeRequest(t, req, http.StatusOK)
 	DecodeJSON(t, resp, &apiIssues)
-	assert.Len(t, apiIssues, 11)
+	assert.Len(t, apiIssues, 12)
 	query.Del("since")
 	query.Del("before")
 
@@ -394,7 +394,7 @@ func TestSearchIssues(t *testing.T) {
 	req = NewRequest(t, "GET", link.String())
 	resp = session.MakeRequest(t, req, http.StatusOK)
 	DecodeJSON(t, resp, &apiIssues)
-	assert.EqualValues(t, "20", resp.Header().Get("X-Total-Count"))
+	assert.EqualValues(t, "21", resp.Header().Get("X-Total-Count"))
 	assert.Len(t, apiIssues, 20)
 
 	query.Add("limit", "5")
@@ -402,7 +402,7 @@ func TestSearchIssues(t *testing.T) {
 	req = NewRequest(t, "GET", link.String())
 	resp = session.MakeRequest(t, req, http.StatusOK)
 	DecodeJSON(t, resp, &apiIssues)
-	assert.EqualValues(t, "20", resp.Header().Get("X-Total-Count"))
+	assert.EqualValues(t, "21", resp.Header().Get("X-Total-Count"))
 	assert.Len(t, apiIssues, 5)
 
 	query = url.Values{"assigned": {"true"}, "state": {"all"}}
@@ -451,7 +451,7 @@ func TestSearchIssues(t *testing.T) {
 func TestSearchIssuesWithLabels(t *testing.T) {
 	defer tests.PrepareTestEnv(t)()
 
-	expectedIssueCount := 18 // from the fixtures
+	expectedIssueCount := 19 // from the fixtures
 	if expectedIssueCount > setting.UI.IssuePagingNum {
 		expectedIssueCount = setting.UI.IssuePagingNum
 	}