diff options
author | Jimmy Praet <jimmy.praet@telenet.be> | 2021-11-22 13:20:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 20:20:16 +0800 |
commit | a3efd048a7770aff898096df55eda76e80a4972e (patch) | |
tree | aea86e365fed219016a2d2e106572fde6a5b7e84 /models/issues/content_history_test.go | |
parent | 49b2cb998b6ebaf98e89dd9dba8ba9d46d2fd82c (diff) | |
download | gitea-a3efd048a7770aff898096df55eda76e80a4972e.tar.gz gitea-a3efd048a7770aff898096df55eda76e80a4972e.zip |
Improvements to content history (#17746)
* Improvements to content history
* initialize content history when making an edit to an old item created before the introduction of content history
* show edit history for code comments on pull request files tab
* Fix a flaw in keepLimitedContentHistory
Fix a flaw in keepLimitedContentHistory, the first and the last should never be deleted
* Remove obsolete eager initialization of content history
Diffstat (limited to 'models/issues/content_history_test.go')
-rw-r--r-- | models/issues/content_history_test.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/models/issues/content_history_test.go b/models/issues/content_history_test.go index f040a7dc57..cc9a7c5107 100644 --- a/models/issues/content_history_test.go +++ b/models/issues/content_history_test.go @@ -53,6 +53,11 @@ func TestContentHistory(t *testing.T) { list2, _ := FetchIssueContentHistoryList(dbCtx, 10, 100) assert.Len(t, list2, 5) + hasHistory1, _ := HasIssueContentHistory(dbCtx, 10, 0) + assert.True(t, hasHistory1) + hasHistory2, _ := HasIssueContentHistory(dbCtx, 10, 1) + assert.False(t, hasHistory2) + h6, h6Prev, _ := GetIssueContentHistoryAndPrev(dbCtx, 6) assert.EqualValues(t, 6, h6.ID) assert.EqualValues(t, 5, h6Prev.ID) @@ -63,13 +68,13 @@ func TestContentHistory(t *testing.T) { assert.EqualValues(t, 6, h6.ID) assert.EqualValues(t, 4, h6Prev.ID) - // only keep 3 history revisions for comment_id=100 + // only keep 3 history revisions for comment_id=100, the first and the last should never be deleted keepLimitedContentHistory(dbEngine, 10, 100, 3) list1, _ = FetchIssueContentHistoryList(dbCtx, 10, 0) assert.Len(t, list1, 3) list2, _ = FetchIssueContentHistoryList(dbCtx, 10, 100) assert.Len(t, list2, 3) - assert.EqualValues(t, 7, list2[0].HistoryID) - assert.EqualValues(t, 6, list2[1].HistoryID) + assert.EqualValues(t, 8, list2[0].HistoryID) + assert.EqualValues(t, 7, list2[1].HistoryID) assert.EqualValues(t, 4, list2[2].HistoryID) } |