From 093df05b65770e5d2164f15702effc13e5976b12 Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 3 Jan 2018 13:44:13 -0600 Subject: [PATCH] edit to pointer, allowing omitempty --- app/migrator/remark_test.go | 2 +- app/store/service.go | 2 +- app/store/store.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/migrator/remark_test.go b/app/migrator/remark_test.go index e49b89c5..1124e403 100644 --- a/app/migrator/remark_test.go +++ b/app/migrator/remark_test.go @@ -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, link","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, link","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) } diff --git a/app/store/service.go b/app/store/service.go index 4be80327..ce9fab8a 100644 --- a/app/store/service.go +++ b/app/store/service.go @@ -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) diff --git a/app/store/store.go b/app/store/store.go index a71126b3..95ea9698 100644 --- a/app/store/store.go +++ b/app/store/store.go @@ -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