// Copyright 2017 Frédéric Guillot. All rights reserved.
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
package processor // import "miniflux.app/reader/processor"
import (
"miniflux.app/reader/parser"
"testing"
)
func TestKeeplistRules(t *testing.T) {
data := `
SomeGood News
http://foo.bar/
Kitten News
http://kitties.today/daily-kitten
Kitten picture of the day.Tue, 03 Jun 2003 09:39:21 GMThttp://kitties.todayDaily Covid DoomScrolling News
http://covid.doom/daily-panic-dose
Did you know that you can get COVID IN YOUR DREAMS?.Tue, 03 Jun 2020 09:39:21 GMThttp://covid.doom`
feed, err := parser.ParseFeed(data)
if err != nil {
t.Error(err)
}
if len(feed.Entries) != 2 {
t.Errorf("Error parsing feed")
}
//case insensitive
feed.KeeplistRules = "(?i)kitten"
filterFeedEntries(feed)
if len(feed.Entries) != 1 {
t.Errorf("Keeplist filter rule did not properly filter the feed")
}
}
func TestBlocklistRules(t *testing.T) {
data := `
SomeGood News
http://foo.bar/
Kitten News
http://kitties.today/daily-kitten
Kitten picture of the day.Tue, 03 Jun 2003 09:39:21 GMThttp://kitties.todayDaily Covid DoomScrolling News
http://covid.doom/daily-panic-dose
Did you know that you can get COVID IN YOUR DREAMS?.Tue, 03 Jun 2020 09:39:21 GMThttp://covid.doom`
feed, err := parser.ParseFeed(data)
if err != nil {
t.Error(err)
}
if len(feed.Entries) != 2 {
t.Errorf("Error parsing feed")
}
//case insensitive
feed.BlocklistRules = "(?i)covid"
filterFeedEntries(feed)
if len(feed.Entries) != 1 {
t.Errorf("Keeplist filter rule did not properly filter the feed")
}
}