diff --git a/app/store/bolt.go b/app/store/bolt.go index 2a8f37fa..b1782a49 100644 --- a/app/store/bolt.go +++ b/app/store/bolt.go @@ -250,7 +250,9 @@ func (b *BoltDB) Last(siteID string, max int) (comments []Comment, err error) { log.Printf("[WARN] can't load comment for %s from store %s", commentID, url) continue } - + if comment.Deleted { + continue + } comments = append(comments, comment) if len(comments) >= max { break diff --git a/app/store/bolt_test.go b/app/store/bolt_test.go index 5303679b..95db7822 100644 --- a/app/store/bolt_test.go +++ b/app/store/bolt_test.go @@ -33,7 +33,7 @@ func TestBoltDB_Delete(t *testing.T) { loc := Locator{URL: "https://radio-t.com", SiteID: "radio-t"} res, err := b.Find(loc, "time") assert.Nil(t, err) - assert.Equal(t, 2, len(res)) + assert.Equal(t, 2, len(res), "initially 2 comments") err = b.Delete(loc, res[0].ID) assert.Nil(t, err) @@ -48,9 +48,7 @@ func TestBoltDB_Delete(t *testing.T) { comments, err := b.Last("radio-t", 10) assert.Nil(t, err) - assert.Equal(t, 2, len(comments), "2 in last, nothing removed") - assert.Equal(t, "this comment was deleted", comments[1].Text) - assert.True(t, comments[1].Deleted, "marked deleted") + assert.Equal(t, 1, len(comments), "1 in last, 1 removed") } func TestBoltDB_Get(t *testing.T) {