mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
Refactor feed creation to allow setting most fields via API
Allow API clients to create disabled feeds or define field like "ignore_http_cache".
This commit is contained in:
parent
ab82c4b300
commit
f0610bdd9c
26 changed files with 370 additions and 264 deletions
|
@ -73,19 +73,6 @@ func (f *Feed) WithCategoryID(categoryID int64) {
|
|||
f.Category = &Category{ID: categoryID}
|
||||
}
|
||||
|
||||
// WithBrowsingParameters defines browsing parameters.
|
||||
func (f *Feed) WithBrowsingParameters(crawler bool, userAgent, username, password, scraperRules, rewriteRules, blocklistRules, keeplistRules string, fetchViaProxy bool) {
|
||||
f.Crawler = crawler
|
||||
f.UserAgent = userAgent
|
||||
f.Username = username
|
||||
f.Password = password
|
||||
f.ScraperRules = scraperRules
|
||||
f.RewriteRules = rewriteRules
|
||||
f.FetchViaProxy = fetchViaProxy
|
||||
f.BlocklistRules = blocklistRules
|
||||
f.KeeplistRules = keeplistRules
|
||||
}
|
||||
|
||||
// WithError adds a new error message and increment the error counter.
|
||||
func (f *Feed) WithError(message string) {
|
||||
f.ParsingErrorCount++
|
||||
|
|
|
@ -46,57 +46,6 @@ func TestFeedCategorySetter(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestFeedBrowsingParams(t *testing.T) {
|
||||
feed := &Feed{}
|
||||
feed.WithBrowsingParameters(
|
||||
true,
|
||||
"Custom User Agent",
|
||||
"Username",
|
||||
"Secret",
|
||||
"Scraper Rule",
|
||||
"Rewrite Rule",
|
||||
"Block Rule",
|
||||
"Allow Rule",
|
||||
true,
|
||||
)
|
||||
|
||||
if !feed.Crawler {
|
||||
t.Error(`The crawler must be activated`)
|
||||
}
|
||||
|
||||
if feed.UserAgent != "Custom User Agent" {
|
||||
t.Error(`The user agent must be set`)
|
||||
}
|
||||
|
||||
if feed.Username != "Username" {
|
||||
t.Error(`The username must be set`)
|
||||
}
|
||||
|
||||
if feed.Password != "Secret" {
|
||||
t.Error(`The password must be set`)
|
||||
}
|
||||
|
||||
if feed.ScraperRules != "Scraper Rule" {
|
||||
t.Errorf(`The scraper rules must be set`)
|
||||
}
|
||||
|
||||
if feed.RewriteRules != "Rewrite Rule" {
|
||||
t.Errorf(`The rewrite rules must be set`)
|
||||
}
|
||||
|
||||
if feed.BlocklistRules != "Block Rule" {
|
||||
t.Errorf(`The block list rules must be set`)
|
||||
}
|
||||
|
||||
if feed.KeeplistRules != "Allow Rule" {
|
||||
t.Errorf(`The keep list rules must be set`)
|
||||
}
|
||||
|
||||
if !feed.FetchViaProxy {
|
||||
t.Errorf(`The fetch via proxy is no set`)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFeedErrorCounter(t *testing.T) {
|
||||
feed := &Feed{}
|
||||
feed.WithError("Some Error")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue