-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented support for RSS <content:encoded>
- Loading branch information
Showing
5 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package rss | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
) | ||
|
||
func TestParseAtomTitle(t *testing.T) { | ||
tests := map[string]string{ | ||
"atom_1.0": "Titel des Weblogs", | ||
"atom_1.0_enclosure": "Titel des Weblogs", | ||
"atom_1.0-1": "Golem.de", | ||
} | ||
|
||
for test, want := range tests { | ||
data, err := ioutil.ReadFile("testdata/" + test) | ||
if err != nil { | ||
t.Fatalf("Reading %s: %v", test, err) | ||
} | ||
|
||
feed, err := Parse(data) | ||
if err != nil { | ||
t.Fatalf("Parsing %s: %v", test, err) | ||
} | ||
|
||
if feed.Title != want { | ||
t.Fatalf("%s: expected %s, got %s", test, want, feed.Title) | ||
} | ||
} | ||
} | ||
|
||
func TestParseAtomContent(t *testing.T) { | ||
tests := map[string]string{ | ||
"atom_1.0": "Volltext des Weblog-Eintrags", | ||
"atom_1.0_enclosure": "Volltext des Weblog-Eintrags", | ||
"atom_1.0-1": "", | ||
} | ||
|
||
for test, want := range tests { | ||
data, err := ioutil.ReadFile("testdata/" + test) | ||
if err != nil { | ||
t.Fatalf("Reading %s: %v", test, err) | ||
} | ||
|
||
feed, err := Parse(data) | ||
if err != nil { | ||
t.Fatalf("Parsing %s: %v", test, err) | ||
} | ||
|
||
if feed.Items[0].Content != want { | ||
t.Fatalf("%s: expected %s, got %s", test, want, feed.Items[0].Content) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package rss | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
) | ||
|
||
func TestParseRSS(t *testing.T) { | ||
tests := map[string]string{ | ||
"rss_1.0": "Golem.de", | ||
} | ||
|
||
for test, want := range tests { | ||
data, err := ioutil.ReadFile("testdata/" + test) | ||
if err != nil { | ||
t.Fatalf("Reading %s: %v", test, err) | ||
} | ||
|
||
feed, err := Parse(data) | ||
if err != nil { | ||
t.Fatalf("Parsing %s: %v", test, err) | ||
} | ||
|
||
if feed.Title != want { | ||
t.Fatalf("%s: expected %s, got %s", test, want, feed.Title) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package rss | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
) | ||
|
||
func TestParseContent(t *testing.T) { | ||
tests := map[string]string{ | ||
"rss_2.0_content_encoded": "<p><a href=\"https://example.com/\">Example.com</a> is an example site.</p>", | ||
} | ||
|
||
for test, want := range tests { | ||
data, err := ioutil.ReadFile("testdata/" + test) | ||
if err != nil { | ||
t.Fatalf("Reading %s: %v", test, err) | ||
} | ||
|
||
feed, err := Parse(data) | ||
if err != nil { | ||
t.Fatalf("Parsing %s: %v", test, err) | ||
} | ||
|
||
if feed.Items[0].Content != want { | ||
t.Fatalf("%s: expected %s, got %s", test, want, feed.Items[0].Content) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<rss version="2.0" | ||
xmlns:content="http://purl.org/rss/1.0/modules/content/" | ||
> | ||
<channel> | ||
<title>RSS Title</title> | ||
<description>This is an example of an RSS feed</description> | ||
<link>http://www.someexamplerssdomain.com/main.html</link> | ||
<lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000</lastBuildDate> | ||
<pubDate>Mon, 06 Sep 2009 16:45:00 +0000</pubDate> | ||
<ttl>1800</ttl> | ||
|
||
<item> | ||
<title>Example entry</title> | ||
<description>Here is some text containing an interesting | ||
description.</description> | ||
<link>http://www.wikipedia.org/</link> | ||
<guid>unique string per item</guid> | ||
<pubDate>Mon, 06 Sep 2009 16:45:00 +0000</pubDate> | ||
<content:encoded><![CDATA[<p><a href="https://example.com/">Example.com</a> is an example site.</p>]]></content:encoded> | ||
</item> | ||
|
||
</channel> | ||
</rss> |