File: Tests.hs

package info (click to toggle)
haskell-feed 1.3.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 820 kB
  • sloc: haskell: 4,735; xml: 4,315; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,360 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module Text.Atom.Tests
  ( atomTests
  ) where

import Prelude.Compat

import Data.Maybe (isJust)
import Test.Framework (Test, mutuallyExclusive, testGroup)
import Test.Framework.Providers.HUnit (testCase)
import Test.HUnit (Assertion, assertBool)
import Text.XML

import Text.Atom.Feed (TextContent(TextString), entryLinks, nullEntry, nullLink)
import Text.Feed.Export (xmlFeed)
import Text.Feed.Import (parseFeedFromFile)
import Text.Feed.Query
import Text.Feed.Types
import Text.RSS.Utils

import Paths_feed

atomTests :: Test
atomTests =
  testGroup
    "Text.Atom"
    [mutuallyExclusive $ testGroup "Atom" [testFullAtomParse, testAtomAlternate]]

testFullAtomParse :: Test
testFullAtomParse = testCase "parse a complete atom file" testAtom
  where
    testAtom :: Assertion
    testAtom = do
      contents <- parseFeedFromFile =<< getDataFileName "tests/files/atom.xml"
      let res = fmap (renderText def) . (>>= elementToDoc) . fmap xmlFeed $ contents
      assertBool "Atom Parsing" $ isJust res

testAtomAlternate :: Test
testAtomAlternate = testCase "*unspecified* link relation means 'alternate'" testAlt
  where
    testAlt :: Assertion
    testAlt =
      let nullent = nullEntry "" (TextString "") ""
          item = AtomItem nullent {entryLinks = [nullLink ""]}
       in assertBool "unspecified means alternate" $ isJust $ getItemLink item