1
0
Fork 0
forked from forgejo/forgejo

Fix issue updated_unix bug (#2204)

This commit is contained in:
Ethan Koenig 2017-07-26 18:20:38 -07:00 committed by Lunny Xiao
parent 5f37944dff
commit a27863b6d1
5 changed files with 73 additions and 0 deletions

View file

@ -7,6 +7,7 @@ package models
import (
"sort"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
@ -146,3 +147,23 @@ func TestIssue_ClearLabels(t *testing.T) {
AssertNotExistsBean(t, &IssueLabel{IssueID: test.issueID})
}
}
func TestUpdateIssueCols(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())
issue := AssertExistsAndLoadBean(t, &Issue{}).(*Issue)
const newTitle = "New Title for unit test"
issue.Title = newTitle
prevContent := issue.Content
issue.Content = "This should have no effect"
now := time.Now().Unix()
assert.NoError(t, UpdateIssueCols(issue, "name"))
then := time.Now().Unix()
updatedIssue := AssertExistsAndLoadBean(t, &Issue{ID: issue.ID}).(*Issue)
assert.EqualValues(t, newTitle, updatedIssue.Title)
assert.EqualValues(t, prevContent, updatedIssue.Content)
AssertInt64InRange(t, now, then, updatedIssue.UpdatedUnix)
}