subscription_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. //go:build integration
  4. // +build integration
  5. package tests
  6. import (
  7. "testing"
  8. miniflux "miniflux.app/v2/client"
  9. )
  10. func TestDiscoverSubscriptions(t *testing.T) {
  11. client := createClient(t)
  12. subscriptions, err := client.Discover(testWebsiteURL)
  13. if err != nil {
  14. t.Fatal(err)
  15. }
  16. if len(subscriptions) != 1 {
  17. t.Fatalf(`Invalid number of subscriptions, got "%v" instead of "%v"`, len(subscriptions), 2)
  18. }
  19. if subscriptions[0].Title != testSubscriptionTitle {
  20. t.Fatalf(`Invalid feed title, got "%v" instead of "%v"`, subscriptions[0].Title, testSubscriptionTitle)
  21. }
  22. if subscriptions[0].Type != "atom" {
  23. t.Fatalf(`Invalid feed type, got "%v" instead of "%v"`, subscriptions[0].Type, "atom")
  24. }
  25. if subscriptions[0].URL != testFeedURL {
  26. t.Fatalf(`Invalid feed URL, got "%v" instead of "%v"`, subscriptions[0].URL, testFeedURL)
  27. }
  28. }
  29. func TestDiscoverSubscriptionsWithInvalidURL(t *testing.T) {
  30. client := createClient(t)
  31. _, err := client.Discover("invalid")
  32. if err == nil {
  33. t.Fatal(`Invalid URLs should be rejected`)
  34. }
  35. }
  36. func TestDiscoverSubscriptionsWithNoSubscription(t *testing.T) {
  37. client := createClient(t)
  38. _, err := client.Discover(testBaseURL)
  39. if err != miniflux.ErrNotFound {
  40. t.Fatal(`A 404 should be returned when there is no subscription`)
  41. }
  42. }