summaryrefslogtreecommitdiff
path: root/tests/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2016-04-21 21:16:52 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2016-04-21 21:16:52 +0200
commitf90585648ea183afd3361defccbc0a934f240a7c (patch)
tree32fcceac3bce8f4525146becb64e94391d87be39 /tests/Hakyll
parent665ee0c309dd92e623a866da9e7584c92f1f3ea4 (diff)
downloadhakyll-f90585648ea183afd3361defccbc0a934f240a7c.tar.gz
Fix test failure
Diffstat (limited to 'tests/Hakyll')
-rw-r--r--tests/Hakyll/Core/Provider/Metadata/Tests.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/Hakyll/Core/Provider/Metadata/Tests.hs b/tests/Hakyll/Core/Provider/Metadata/Tests.hs
index fc609f2..a640f42 100644
--- a/tests/Hakyll/Core/Provider/Metadata/Tests.hs
+++ b/tests/Hakyll/Core/Provider/Metadata/Tests.hs
@@ -11,7 +11,7 @@ import qualified Data.Yaml as Yaml
import Hakyll.Core.Metadata
import Hakyll.Core.Provider.Metadata
import Test.Framework (Test, testGroup)
-import Test.HUnit (Assertion, (@=?))
+import Test.HUnit (Assertion, (@=?), assertFailure)
import TestSuite.Util
@@ -25,7 +25,7 @@ tests = testGroup "Hakyll.Core.Provider.Metadata.Tests" $
--------------------------------------------------------------------------------
testPage01 :: Assertion
testPage01 =
- Right (meta [("foo", "bar")], "qux\n") @=? parsePage
+ (meta [("foo", "bar")], "qux\n") `expectRight` parsePage
"---\n\
\foo: bar\n\
\---\n\
@@ -35,7 +35,7 @@ testPage01 =
--------------------------------------------------------------------------------
testPage02 :: Assertion
testPage02 =
- Right (meta [("description", descr)], "Hello I am dog\n") @=?
+ (meta [("description", descr)], "Hello I am dog\n") `expectRight`
parsePage
"---\n\
\description: A long description that would look better if it\n\
@@ -52,3 +52,11 @@ testPage02 =
--------------------------------------------------------------------------------
meta :: Yaml.ToJSON a => [(String, a)] -> Metadata
meta pairs = HMS.fromList [(T.pack k, Yaml.toJSON v) | (k, v) <- pairs]
+
+
+--------------------------------------------------------------------------------
+-- | This is useful when the 'Left' side of 'Either' doesn't have an 'Eq'
+-- instance.
+expectRight :: (Eq b, Show a, Show b) => b -> Either a b -> Assertion
+expectRight _ (Left err) = assertFailure (show err)
+expectRight expected (Right res) = expected @=? res