mirror of
https://github.com/miniflux/v2.git
synced 2025-08-01 17:38:37 +00:00
Validate Keep list and Block list rules syntax
This commit is contained in:
parent
05fd83bd6f
commit
e8d0360e64
19 changed files with 173 additions and 23 deletions
|
@ -202,6 +202,55 @@ func TestCreateFeedWithScraperRule(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCreateFeedWithKeeplistRule(t *testing.T) {
|
||||
client := createClient(t)
|
||||
|
||||
categories, err := client.Categories()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
feedID, err := client.CreateFeed(&miniflux.FeedCreationRequest{
|
||||
FeedURL: testFeedURL,
|
||||
CategoryID: categories[0].ID,
|
||||
KeeplistRules: "(?i)miniflux",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if feedID == 0 {
|
||||
t.Fatalf(`Invalid feed ID, got %q`, feedID)
|
||||
}
|
||||
|
||||
feed, err := client.Feed(feedID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if feed.KeeplistRules != "(?i)miniflux" {
|
||||
t.Error(`The feed should have the custom keep list rule saved`)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateFeedWithInvalidBlocklistRule(t *testing.T) {
|
||||
client := createClient(t)
|
||||
|
||||
categories, err := client.Categories()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = client.CreateFeed(&miniflux.FeedCreationRequest{
|
||||
FeedURL: testFeedURL,
|
||||
CategoryID: categories[0].ID,
|
||||
BlocklistRules: "[",
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal(`Feed with invalid block list rule should not be created`)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateFeedURL(t *testing.T) {
|
||||
client := createClient(t)
|
||||
feed, _ := createFeed(t, client)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue