1
0
Fork 0
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:
Frédéric Guillot 2021-02-07 18:38:45 -08:00 committed by fguillot
parent 05fd83bd6f
commit e8d0360e64
19 changed files with 173 additions and 23 deletions

View file

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