Browse Source

tidy: quick fix cache_test (#699)

I just realized that the cache test I implemented last night was failing, and when I looked into it it was because the cache test didn't reflect the updated logic that had been found to work in post_handler, so here's a small hotfix to tidy that up.

Co-authored-by: servusdei2018 <servusdei@programmer.net>
Reviewed-on: #699
Co-authored-by: servusdei2018 <servusdei2018@noreply@mills.io>
Co-committed-by: servusdei2018 <servusdei2018@noreply@mills.io>
pull/706/head
servusdei2018 1 week ago
committed by James Mills
parent
commit
7bbbb408ae
  1. 17
      internal/cache_test.go

17
internal/cache_test.go

@ -6,7 +6,6 @@ import (
"net"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
@ -456,10 +455,8 @@ func TestCache_Snipe(t *testing.T) {
cache.SnipeFeed(badtwt.Twter().URL, badtwt)
for key, feed := range cache.Views {
if strings.HasSuffix(key, discoverViewKey) {
feed.Snipe(badtwt)
}
for _, feed := range cache.Views {
feed.Snipe(badtwt)
}
assert.Equal(t, 2, cache.TwtCount())
@ -469,19 +466,21 @@ func TestCache_Snipe(t *testing.T) {
//
// Check cache.Feeds
for _, cached := range cache.Feeds {
for key, cached := range cache.Feeds {
for _, twt := range cached.GetTwts() {
if twt.Hash() == badtwt.Hash() {
assert.Error(t, nil, "twt deleted but found in Cache.Feeds")
err := fmt.Errorf("error, deleted twt found in Cache.Feeds[%s]", key)
assert.Error(t, err, "twt deleted but found in Cache.Feeds")
}
}
}
// Check cache.Views
for _, cached := range cache.Views {
for key, cached := range cache.Views {
for _, twt := range cached.GetTwts() {
if twt.Hash() == badtwt.Hash() {
assert.Error(t, nil, "twt deleted but found in Cache.Views")
err := fmt.Errorf("error, deleted twt found in Cache.Views[%s]", key)
assert.Error(t, err, "twt deleted but found in Cache.Views")
}
}
}

Loading…
Cancel
Save