Record work item comments revisions (#914) #930
Record work item comments revisions (#914) #930
Conversation
Added a `comment_revisions` table to retain all changes on comments, along with a timestamp, the Id of the author identity and the type of operation that was performed. When the comment is deleted, the 'body' and 'markup' fields are 'Nil'. The list of revisions is retrieved in its historical order. Also renamed the `workitem.WorkItemRevision` to `workitem.Revision` and removed the `WorkItem` part in the revision constants. Fixes fabric8-services#914 Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
comment/comment_revision.go
Outdated
// RevisionTypeDelete a work item deletion | ||
RevisionTypeDelete // 2 | ||
_ // ignore 3rd value | ||
// RevisionTypeUpdate a work item update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn'it !
workitem/workitem_revision.go
Outdated
@@ -6,22 +6,22 @@ import ( | |||
uuid "github.com/satori/go.uuid" | |||
) | |||
|
|||
// RevisionType defines the type of revision for a work item | |||
// WorkIteRevisionTypemRevisionType defines the type of revision for a work item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
Codecov Report
@@ Coverage Diff @@
## master #930 +/- ##
==========================================
+ Coverage 68.59% 68.63% +0.04%
==========================================
Files 91 93 +2
Lines 6916 6957 +41
==========================================
+ Hits 4744 4775 +31
- Misses 1730 1735 +5
- Partials 442 447 +5
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM , some minor comments.
assert.Equal(s.T(), rendering.SystemMarkupMarkdown, *revision1.CommentMarkup) | ||
assert.Equal(s.T(), s.testIdentity1.ID, revision1.ModifierIdentity) | ||
// revision 2 | ||
revision2 := commentRevisions[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm torn between
Whether we should move repetitive code inside a different method ,
and
the prospect of losing line numbers in case of error.
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me see what I can about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, code would look like this:
expectedBody := "Body"
expectedMarkup := rendering.SystemMarkupMarkdown
expectedRevision := comment.Revision{
CommentID: c.ID,
ModifierIdentity: s.testIdentity1.ID,
Type: comment.RevisionTypeCreate,
CommentBody: &expectedBody,
CommentMarkup: &expectedMarkup,
}
s.assertRevision(revision1, expectedRevision)
along with
func (s *revisionRepositoryBlackBoxTest) assertRevision(expected, actual comment.Revision) {
assert.Equal(s.T(), expected.ID, actual.CommentID)
assert.Equal(s.T(), expected.Type, actual.Type)
assert.Equal(s.T(), expected.ModifierIdentity, actual.ModifierIdentity)
assert.Equal(s.T(), expected.CommentBody, *actual.CommentBody)
assert.Equal(s.T(), expected.CommentMarkup, *actual.CommentMarkup)
}
so there's no real benefit in terms of readability and number of lines, and indeed, in case of assertion error, we would not know which revision is wrong..
} | ||
|
||
func (s *revisionRepositoryBlackBoxTest) TearDownTest() { | ||
//s.clean() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha yes, good point. I removed it during my last tests to verify the state of the data in the DB. Let me remove the comment.
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
…ervices#930) * Record work item comments revisions (fabric8-services#914) Added a `comment_revisions` table to retain all changes on comments, along with a timestamp, the Id of the author identity and the type of operation that was performed. When the comment is deleted, the 'body' and 'markup' fields are 'Nil'. The list of revisions is retrieved in its historical order. Also renamed the `workitem.WorkItemRevision` to `workitem.Revision` and removed the `WorkItem` part in the revision constants. Fixes fabric8-services#914 Signed-off-by: Xavier Coulon <xcoulon@redhat.com>
Added a
comment_revisions
table to retain all changes on comments,along with a timestamp, the Id of the author identity and the type
of operation that was performed.
When the comment is deleted, the 'body' and 'markup' fields are 'Nil'.
The list of revisions is retrieved in its historical order.
Also renamed the
workitem.WorkItemRevision
toworkitem.Revision
and removed the
WorkItem
part in the revision constants.Fixes #914
Signed-off-by: Xavier Coulon xcoulon@redhat.com