aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFélix Sipma <felix.sipma@no-log.org>2017-01-13 17:01:18 +0100
committerFélix Sipma <felix.sipma@no-log.org>2017-01-13 17:01:18 +0100
commit0827fcfc092e4732dd6ef8cfc6ce49e04f1996ab (patch)
treeeb22861367800f6da6f7a2043de0b6ea7f3a55e5
parentd9cd01def7234e5a9315c75875f6115cacd2327f (diff)
add RSS2 feed parsing test
-rw-r--r--test/Spec.hs59
-rw-r--r--test/files/rss20.xml33
2 files changed, 92 insertions, 0 deletions
diff --git a/test/Spec.hs b/test/Spec.hs
index 3f431da..528a2d6 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -7,6 +7,7 @@ import Test.Hspec hiding (shouldBe)
import Test.Hspec.Expectations.Pretty (shouldBe)
import Parse (cursorFromFile)
import Atom (parseAtomFeed)
+import RSS (parseRSSFeed)
import RSS1 (parseRSS1Feed)
import Control.Monad.Logger (runStderrLoggingT)
import Types
@@ -25,6 +26,10 @@ spec = describe "Feed parsing" $ do
c <- liftIO $ cursorFromFile "test/files/rss10.xml"
mf <- runStderrLoggingT (parseRSS1Feed "http://example.com" c)
mf `shouldBe` Just rss1Feed
+ it "can parse an RSS2 feed" $ do
+ c <- liftIO $ cursorFromFile "test/files/rss20.xml"
+ mf <- runStderrLoggingT (parseRSSFeed "http://example.com" c)
+ mf `shouldBe` Just rssFeed
atomFeed = Feed {
feedId = "http://example.com",
@@ -161,3 +166,57 @@ rss1Feed = Feed {
}
]
}
+
+rssFeed = Feed {
+ feedId = "http://example.com",
+ feedTitle = "Planet Example",
+ feedUpdated = read "2015-07-31 16:04:00 UTC",
+ feedAuthors = [],
+ feedLinks = [
+ Link {
+ linkHref = "http://planet.example.com/",
+ linkRel = Nothing
+ }
+ ],
+ feedEntries = [
+ Entry {
+ entryId = "http://blog.example.com/2015/07/31#Example-release",
+ entryTitle = "My Example 1",
+ entryUpdated = read "2015-07-31 16:04:00 UTC",
+ entryAuthors = [],
+ entryContent = Just (HtmlContent "<p>Example 1</p>"),
+ entryLinks = [
+ Link {
+ linkHref = "http://blog.example.com/2015/07/31#Example-release",
+ linkRel = Nothing
+ }
+ ]
+ },
+ Entry {
+ entryId = "https://example.com/?p=3300",
+ entryTitle = "Other Example",
+ entryUpdated = read "2015-07-31 14:45:30 UTC",
+ entryAuthors = [],
+ entryContent = Just (HtmlContent "<p>This is not an example</p>"),
+ entryLinks = [
+ Link {
+ linkHref = "https://example.com/2015/07/31/my-example/",
+ linkRel = Nothing
+ }
+ ]
+ },
+ Entry {
+ entryId = "tag:blog.example.com,2015-07-31:example-4.html",
+ entryTitle = "An example: 4",
+ entryUpdated = read "2015-07-31 07:15:18 UTC",
+ entryAuthors = [],
+ entryContent = Just (HtmlContent "<p>My Example number 4</p>"),
+ entryLinks = [
+ Link {
+ linkHref = "http://blog.example.com/example-4.html",
+ linkRel = Nothing
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/files/rss20.xml b/test/files/rss20.xml
new file mode 100644
index 0000000..ad4768e
--- /dev/null
+++ b/test/files/rss20.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<rss version="2.0">
+
+<channel>
+ <title>Planet Example</title>
+ <link>http://planet.example.com/</link>
+ <language>en</language>
+ <description>Planet Example - http://planet.example.com/</description>
+
+<item>
+ <title>My Example 1</title>
+ <guid>http://blog.example.com/2015/07/31#Example-release</guid>
+ <link>http://blog.example.com/2015/07/31#Example-release</link>
+ <description>&lt;p&gt;Example 1&lt;/p&gt;</description>
+ <pubDate>Fri, 31 Jul 2015 16:04:00 +0000</pubDate>
+</item>
+<item>
+ <title>Other Example</title>
+ <guid>https://example.com/?p=3300</guid>
+ <link>https://example.com/2015/07/31/my-example/</link>
+ <description>&lt;p&gt;This is not an example&lt;/p&gt;</description>
+ <pubDate>Fri, 31 Jul 2015 14:45:30 +0000</pubDate>
+</item>
+<item>
+ <title>An example: 4</title>
+ <guid>tag:blog.example.com,2015-07-31:example-4.html</guid>
+ <link>http://blog.example.com/example-4.html</link>
+ <description>&lt;p&gt;My Example number 4&lt;/p&gt;</description>
+ <pubDate>Fri, 31 Jul 2015 07:15:18 +0000</pubDate>
+</item>
+
+</channel>
+</rss>