aboutsummaryrefslogtreecommitdiffhomepage
path: root/model
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2019-11-29 11:17:14 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2019-11-29 11:27:58 -0800
commit69aa650203087ad6365fcd6769a49bdf327e9efb (patch)
tree2b74ede78da683a9442da0851718d981614a37b7 /model
parent8028cc764ff7d53370b64ec8110cbcdece787432 (diff)
Add the possibility to add rules during feed creation
Diffstat (limited to 'model')
-rw-r--r--model/feed.go4
-rw-r--r--model/feed_test.go10
2 files changed, 12 insertions, 2 deletions
diff --git a/model/feed.go b/model/feed.go
index 9d0ab27..5782c4f 100644
--- a/model/feed.go
+++ b/model/feed.go
@@ -61,11 +61,13 @@ func (f *Feed) WithCategoryID(categoryID int64) {
}
// WithBrowsingParameters defines browsing parameters.
-func (f *Feed) WithBrowsingParameters(crawler bool, userAgent, username, password string) {
+func (f *Feed) WithBrowsingParameters(crawler bool, userAgent, username, password, scraperRules, rewriteRules string) {
f.Crawler = crawler
f.UserAgent = userAgent
f.Username = username
f.Password = password
+ f.ScraperRules = scraperRules
+ f.RewriteRules = rewriteRules
}
// WithError adds a new error message and increment the error counter.
diff --git a/model/feed_test.go b/model/feed_test.go
index 8cbb00b..27ef897 100644
--- a/model/feed_test.go
+++ b/model/feed_test.go
@@ -44,7 +44,7 @@ func TestFeedCategorySetter(t *testing.T) {
func TestFeedBrowsingParams(t *testing.T) {
feed := &Feed{}
- feed.WithBrowsingParameters(true, "Custom User Agent", "Username", "Secret")
+ feed.WithBrowsingParameters(true, "Custom User Agent", "Username", "Secret", "Some Rule", "Another Rule")
if !feed.Crawler {
t.Error(`The crawler must be activated`)
@@ -61,6 +61,14 @@ func TestFeedBrowsingParams(t *testing.T) {
if feed.Password != "Secret" {
t.Error(`The password must be set`)
}
+
+ if feed.ScraperRules != "Some Rule" {
+ t.Errorf(`The scraper rules must be set`)
+ }
+
+ if feed.RewriteRules != "Another Rule" {
+ t.Errorf(`The rewrite rules must be set`)
+ }
}
func TestFeedErrorCounter(t *testing.T) {