summaryrefslogtreecommitdiffstats
path: root/models/action_test.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-02-27 20:42:10 -0500
committerLunny Xiao <xiaolunwen@gmail.com>2017-02-28 09:42:10 +0800
commit4b286f282a38d55b2271c43db80d3ac938746c79 (patch)
tree26995996ee01bc3e5a3224b334557b4af2433317 /models/action_test.go
parentcf80e191578618d94f32a0d1dece3169c4f99bf2 (diff)
downloadgitea-4b286f282a38d55b2271c43db80d3ac938746c79.tar.gz
gitea-4b286f282a38d55b2271c43db80d3ac938746c79.zip
Consistency checks for action unit tests (#1079)
Diffstat (limited to 'models/action_test.go')
-rw-r--r--models/action_test.go19
1 files changed, 16 insertions, 3 deletions
diff --git a/models/action_test.go b/models/action_test.go
index f29ec65cfc..cb36966ec7 100644
--- a/models/action_test.go
+++ b/models/action_test.go
@@ -1,9 +1,11 @@
package models
import (
+ "strings"
"testing"
"code.gitea.io/gitea/modules/setting"
+
"github.com/stretchr/testify/assert"
)
@@ -46,6 +48,7 @@ func TestNewRepoAction(t *testing.T) {
AssertNotExistsBean(t, actionBean)
assert.NoError(t, NewRepoAction(user, repo))
AssertExistsAndLoadBean(t, actionBean)
+ CheckConsistencyFor(t, &Action{})
}
func TestRenameRepoAction(t *testing.T) {
@@ -58,6 +61,7 @@ func TestRenameRepoAction(t *testing.T) {
oldRepoName := repo.Name
const newRepoName = "newRepoName"
repo.Name = newRepoName
+ repo.LowerName = strings.ToLower(newRepoName)
actionBean := &Action{
OpType: ActionRenameRepo,
@@ -72,6 +76,10 @@ func TestRenameRepoAction(t *testing.T) {
AssertNotExistsBean(t, actionBean)
assert.NoError(t, RenameRepoAction(user, oldRepoName, repo))
AssertExistsAndLoadBean(t, actionBean)
+
+ _, err := x.Id(repo.ID).Cols("name", "lower_name").Update(repo)
+ assert.NoError(t, err)
+ CheckConsistencyFor(t, &Action{})
}
func TestPushCommits_ToAPIPayloadCommits(t *testing.T) {
@@ -192,6 +200,7 @@ func TestUpdateIssuesCommit(t *testing.T) {
assert.NoError(t, UpdateIssuesCommit(user, repo, pushCommits))
AssertExistsAndLoadBean(t, commentBean)
AssertExistsAndLoadBean(t, issueBean, "is_closed=1")
+ CheckConsistencyFor(t, &Action{})
}
func TestCommitRepoAction(t *testing.T) {
@@ -242,6 +251,7 @@ func TestCommitRepoAction(t *testing.T) {
Commits: pushCommits,
}))
AssertExistsAndLoadBean(t, actionBean)
+ CheckConsistencyFor(t, &Action{})
}
func TestTransferRepoAction(t *testing.T) {
@@ -266,6 +276,10 @@ func TestTransferRepoAction(t *testing.T) {
AssertNotExistsBean(t, actionBean)
assert.NoError(t, TransferRepoAction(user2, user2, repo))
AssertExistsAndLoadBean(t, actionBean)
+
+ _, err := x.Id(repo.ID).Cols("owner_id").Update(repo)
+ assert.NoError(t, err)
+ CheckConsistencyFor(t, &Action{})
}
func TestMergePullRequestAction(t *testing.T) {
@@ -287,6 +301,7 @@ func TestMergePullRequestAction(t *testing.T) {
AssertNotExistsBean(t, actionBean)
assert.NoError(t, MergePullRequestAction(user, repo, issue))
AssertExistsAndLoadBean(t, actionBean)
+ CheckConsistencyFor(t, &Action{})
}
func TestGetFeeds(t *testing.T) {
@@ -318,7 +333,5 @@ func TestGetFeeds2(t *testing.T) {
actions, err = GetFeeds(user, user.ID, 0, true)
assert.NoError(t, err)
- assert.Len(t, actions, 1)
- assert.Equal(t, int64(2), actions[0].ID)
- assert.Equal(t, user.ID, actions[0].UserID)
+ assert.Len(t, actions, 0)
}