// 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) } }) } }