| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
- // SPDX-License-Identifier: Apache-2.0
- package opml // import "miniflux.app/v2/internal/reader/opml"
- import "testing"
- func TestValidateSubscription(t *testing.T) {
- tests := []struct {
- name string
- subscription subcription
- wantErr bool
- }{
- {
- name: "valid feed",
- subscription: subcription{FeedURL: "https://example.org/feed.xml", KeeplistRules: "(?i)golang"},
- wantErr: false,
- },
- {
- name: "unsupported URL scheme",
- subscription: subcription{FeedURL: "feed://example.org/feed.xml"},
- wantErr: true,
- },
- {
- name: "relative URL",
- subscription: subcription{FeedURL: "/feed.xml"},
- wantErr: true,
- },
- {
- name: "invalid keeplist rule",
- subscription: subcription{FeedURL: "https://example.org/feed.xml", KeeplistRules: "["},
- wantErr: true,
- },
- {
- name: "invalid filter rule",
- subscription: subcription{FeedURL: "https://example.org/feed.xml", BlockFilterEntryRules: "Title=foo"},
- wantErr: true,
- },
- }
- for _, tc := range tests {
- t.Run(tc.name, func(t *testing.T) {
- if err := validateSubscription(tc.subscription); (err != nil) != tc.wantErr {
- t.Fatalf("expected error %v, got %v", tc.wantErr, err)
- }
- })
- }
- }
|