1
1
package models
2
2
3
3
import (
4
+ "strings"
4
5
"testing"
5
6
6
7
"code.gitea.io/gitea/modules/setting"
8
+
7
9
"github.com/stretchr/testify/assert"
8
10
)
9
11
@@ -46,6 +48,7 @@ func TestNewRepoAction(t *testing.T) {
46
48
AssertNotExistsBean (t , actionBean )
47
49
assert .NoError (t , NewRepoAction (user , repo ))
48
50
AssertExistsAndLoadBean (t , actionBean )
51
+ CheckConsistencyFor (t , & Action {})
49
52
}
50
53
51
54
func TestRenameRepoAction (t * testing.T ) {
@@ -58,6 +61,7 @@ func TestRenameRepoAction(t *testing.T) {
58
61
oldRepoName := repo .Name
59
62
const newRepoName = "newRepoName"
60
63
repo .Name = newRepoName
64
+ repo .LowerName = strings .ToLower (newRepoName )
61
65
62
66
actionBean := & Action {
63
67
OpType : ActionRenameRepo ,
@@ -72,6 +76,10 @@ func TestRenameRepoAction(t *testing.T) {
72
76
AssertNotExistsBean (t , actionBean )
73
77
assert .NoError (t , RenameRepoAction (user , oldRepoName , repo ))
74
78
AssertExistsAndLoadBean (t , actionBean )
79
+
80
+ _ , err := x .Id (repo .ID ).Cols ("name" , "lower_name" ).Update (repo )
81
+ assert .NoError (t , err )
82
+ CheckConsistencyFor (t , & Action {})
75
83
}
76
84
77
85
func TestPushCommits_ToAPIPayloadCommits (t * testing.T ) {
@@ -192,6 +200,7 @@ func TestUpdateIssuesCommit(t *testing.T) {
192
200
assert .NoError (t , UpdateIssuesCommit (user , repo , pushCommits ))
193
201
AssertExistsAndLoadBean (t , commentBean )
194
202
AssertExistsAndLoadBean (t , issueBean , "is_closed=1" )
203
+ CheckConsistencyFor (t , & Action {})
195
204
}
196
205
197
206
func TestCommitRepoAction (t * testing.T ) {
@@ -242,6 +251,7 @@ func TestCommitRepoAction(t *testing.T) {
242
251
Commits : pushCommits ,
243
252
}))
244
253
AssertExistsAndLoadBean (t , actionBean )
254
+ CheckConsistencyFor (t , & Action {})
245
255
}
246
256
247
257
func TestTransferRepoAction (t * testing.T ) {
@@ -266,6 +276,10 @@ func TestTransferRepoAction(t *testing.T) {
266
276
AssertNotExistsBean (t , actionBean )
267
277
assert .NoError (t , TransferRepoAction (user2 , user2 , repo ))
268
278
AssertExistsAndLoadBean (t , actionBean )
279
+
280
+ _ , err := x .Id (repo .ID ).Cols ("owner_id" ).Update (repo )
281
+ assert .NoError (t , err )
282
+ CheckConsistencyFor (t , & Action {})
269
283
}
270
284
271
285
func TestMergePullRequestAction (t * testing.T ) {
@@ -287,6 +301,7 @@ func TestMergePullRequestAction(t *testing.T) {
287
301
AssertNotExistsBean (t , actionBean )
288
302
assert .NoError (t , MergePullRequestAction (user , repo , issue ))
289
303
AssertExistsAndLoadBean (t , actionBean )
304
+ CheckConsistencyFor (t , & Action {})
290
305
}
291
306
292
307
func TestGetFeeds (t * testing.T ) {
@@ -318,7 +333,5 @@ func TestGetFeeds2(t *testing.T) {
318
333
319
334
actions , err = GetFeeds (user , user .ID , 0 , true )
320
335
assert .NoError (t , err )
321
- assert .Len (t , actions , 1 )
322
- assert .Equal (t , int64 (2 ), actions [0 ].ID )
323
- assert .Equal (t , user .ID , actions [0 ].UserID )
336
+ assert .Len (t , actions , 0 )
324
337
}
0 commit comments