2023-06-19 17:42:47 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2018-08-25 14:53:14 -04:00
|
|
|
|
2022-08-09 00:33:38 -04:00
|
|
|
//go:build integration
|
2018-08-25 14:53:14 -04:00
|
|
|
// +build integration
|
|
|
|
|
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2021-01-04 16:49:28 -05:00
|
|
|
|
2023-08-10 00:15:55 -04:00
|
|
|
miniflux "miniflux.app/v2/client"
|
2018-08-25 14:53:14 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDiscoverSubscriptions(t *testing.T) {
|
|
|
|
client := createClient(t)
|
|
|
|
subscriptions, err := client.Discover(testWebsiteURL)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(subscriptions) != 1 {
|
|
|
|
t.Fatalf(`Invalid number of subscriptions, got "%v" instead of "%v"`, len(subscriptions), 2)
|
|
|
|
}
|
|
|
|
|
2019-11-18 01:53:11 -05:00
|
|
|
if subscriptions[0].Title != testSubscriptionTitle {
|
|
|
|
t.Fatalf(`Invalid feed title, got "%v" instead of "%v"`, subscriptions[0].Title, testSubscriptionTitle)
|
2018-08-25 14:53:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if subscriptions[0].Type != "atom" {
|
|
|
|
t.Fatalf(`Invalid feed type, got "%v" instead of "%v"`, subscriptions[0].Type, "atom")
|
|
|
|
}
|
|
|
|
|
|
|
|
if subscriptions[0].URL != testFeedURL {
|
|
|
|
t.Fatalf(`Invalid feed URL, got "%v" instead of "%v"`, subscriptions[0].URL, testFeedURL)
|
|
|
|
}
|
|
|
|
}
|
2021-01-04 16:49:28 -05:00
|
|
|
|
|
|
|
func TestDiscoverSubscriptionsWithInvalidURL(t *testing.T) {
|
|
|
|
client := createClient(t)
|
|
|
|
_, err := client.Discover("invalid")
|
|
|
|
if err == nil {
|
|
|
|
t.Fatal(`Invalid URLs should be rejected`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDiscoverSubscriptionsWithNoSubscription(t *testing.T) {
|
|
|
|
client := createClient(t)
|
|
|
|
_, err := client.Discover(testBaseURL)
|
|
|
|
if err != miniflux.ErrNotFound {
|
|
|
|
t.Fatal(`A 404 should be returned when there is no subscription`)
|
|
|
|
}
|
|
|
|
}
|