|
|
@@ -4,7 +4,6 @@
|
|
|
package subscription
|
|
|
|
|
|
import (
|
|
|
- "strings"
|
|
|
"testing"
|
|
|
)
|
|
|
|
|
|
@@ -120,7 +119,7 @@ func TestParseWebPageWithRssFeed(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -153,7 +152,7 @@ func TestParseWebPageWithAtomFeed(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -186,7 +185,7 @@ func TestParseWebPageWithJSONFeed(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -219,7 +218,7 @@ func TestParseWebPageWithOldJSONFeedMimeType(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -252,7 +251,7 @@ func TestParseWebPageWithRelativeFeedURL(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -285,7 +284,7 @@ func TestParseWebPageWithEmptyTitle(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -319,7 +318,7 @@ func TestParseWebPageWithMultipleFeeds(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -341,7 +340,7 @@ func TestParseWebPageWithDuplicatedFeeds(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -374,7 +373,7 @@ func TestParseWebPageWithEmptyFeedURL(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -395,7 +394,7 @@ func TestParseWebPageWithNoHref(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", strings.NewReader(htmlPage))
|
|
|
+ subscriptions, err := NewSubscriptionFinder(nil).findSubscriptionsFromWebPage("http://example.org/", "text/html", []byte(htmlPage))
|
|
|
if err != nil {
|
|
|
t.Fatalf(`Parsing a correctly formatted HTML page should not return any error: %v`, err)
|
|
|
}
|
|
|
@@ -416,7 +415,7 @@ func TestFindCanonicalURL(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- canonicalURL := NewSubscriptionFinder(nil).findCanonicalURL("https://example.org/page", "text/html", strings.NewReader(htmlPage))
|
|
|
+ canonicalURL := NewSubscriptionFinder(nil).findCanonicalURL("https://example.org/page", "text/html", []byte(htmlPage))
|
|
|
if canonicalURL != "https://example.org/canonical-page" {
|
|
|
t.Errorf(`Unexpected canonical URL, got %q, expected %q`, canonicalURL, "https://example.org/canonical-page")
|
|
|
}
|
|
|
@@ -432,7 +431,7 @@ func TestFindCanonicalURLNotFound(t *testing.T) {
|
|
|
</body>
|
|
|
</html>`
|
|
|
|
|
|
- canonicalURL := NewSubscriptionFinder(nil).findCanonicalURL("https://example.org/page", "text/html", strings.NewReader(htmlPage))
|
|
|
+ canonicalURL := NewSubscriptionFinder(nil).findCanonicalURL("https://example.org/page", "text/html", []byte(htmlPage))
|
|
|
if canonicalURL != "https://example.org/page" {
|
|
|
t.Errorf(`Expected effective URL when canonical not found, got %q`, canonicalURL)
|
|
|
}
|