subscription_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. //go:build integration
  5. // +build integration
  6. package tests
  7. import (
  8. "testing"
  9. miniflux "miniflux.app/client"
  10. )
  11. func TestDiscoverSubscriptions(t *testing.T) {
  12. client := createClient(t)
  13. subscriptions, err := client.Discover(testWebsiteURL)
  14. if err != nil {
  15. t.Fatal(err)
  16. }
  17. if len(subscriptions) != 1 {
  18. t.Fatalf(`Invalid number of subscriptions, got "%v" instead of "%v"`, len(subscriptions), 2)
  19. }
  20. if subscriptions[0].Title != testSubscriptionTitle {
  21. t.Fatalf(`Invalid feed title, got "%v" instead of "%v"`, subscriptions[0].Title, testSubscriptionTitle)
  22. }
  23. if subscriptions[0].Type != "atom" {
  24. t.Fatalf(`Invalid feed type, got "%v" instead of "%v"`, subscriptions[0].Type, "atom")
  25. }
  26. if subscriptions[0].URL != testFeedURL {
  27. t.Fatalf(`Invalid feed URL, got "%v" instead of "%v"`, subscriptions[0].URL, testFeedURL)
  28. }
  29. }
  30. func TestDiscoverSubscriptionsWithInvalidURL(t *testing.T) {
  31. client := createClient(t)
  32. _, err := client.Discover("invalid")
  33. if err == nil {
  34. t.Fatal(`Invalid URLs should be rejected`)
  35. }
  36. }
  37. func TestDiscoverSubscriptionsWithNoSubscription(t *testing.T) {
  38. client := createClient(t)
  39. _, err := client.Discover(testBaseURL)
  40. if err != miniflux.ErrNotFound {
  41. t.Fatal(`A 404 should be returned when there is no subscription`)
  42. }
  43. }