edit to pointer, allowing omitempty

This commit is contained in:
Umputun
2018-01-03 13:44:13 -06:00
parent 0e1d2494ed
commit 093df05b65
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ func TestRemark_Export(t *testing.T) {
c1, err := buf.ReadString('\n')
assert.Nil(t, err)
log.Print(c1)
exp := `{"id":"efbc17f177ee1a1c0ee6e1e025749966ec071adc","pid":"","text":"some text, <a href=\"http://radio-t.com\" rel=\"nofollow\">link</a>","user":{"name":"user name","id":"user1","picture":"","profile":"","admin":false},"locator":{"site":"radio-t","url":"https://radio-t.com"},"score":0,"votes":{},"time":"2017-12-20T15:18:22-06:00","edit":{"time":"0001-01-01T00:00:00Z","summary":""}}` + "\n"
exp := `{"id":"efbc17f177ee1a1c0ee6e1e025749966ec071adc","pid":"","text":"some text, <a href=\"http://radio-t.com\" rel=\"nofollow\">link</a>","user":{"name":"user name","id":"user1","picture":"","profile":"","admin":false},"locator":{"site":"radio-t","url":"https://radio-t.com"},"score":0,"votes":{},"time":"2017-12-20T15:18:22-06:00"}` + "\n"
assert.Equal(t, exp, c1)
}
+1 -1
View File
@@ -56,7 +56,7 @@ func (s *Service) EditComment(locator Locator, commentID string, text string, ed
}
comment.Text = text
comment.Edit = edit
comment.Edit = &edit
comment.Edit.Timestamp = time.Now()
comment = sanitizeComment(comment)
err = s.Put(locator, comment)
+1 -1
View File
@@ -25,7 +25,7 @@ type Comment struct {
Votes map[string]bool `json:"votes"`
Timestamp time.Time `json:"time"`
Pin bool `json:"pin,omitempty"`
Edit Edit `json:"edit,omitempty"`
Edit *Edit `json:"edit,omitempty"`
}
// Locator keeps site and url of the post