1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

Add the possibility to add rules during feed creation

This commit is contained in:
Frédéric Guillot 2019-11-29 11:17:14 -08:00
parent 8028cc764f
commit 69aa650203
13 changed files with 74 additions and 32 deletions

View file

@ -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.

View file

@ -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) {