summaryrefslogtreecommitdiff
path: root/tests/tasty.hs
diff options
context:
space:
mode:
authorDanny Navarro <j@dannynavarro.net>2015-09-22 13:53:37 +0200
committerDanny Navarro <j@dannynavarro.net>2015-09-22 14:02:49 +0200
commit06b3302862e0c427439136241fb6299f215cec52 (patch)
tree338b9ecc208b4b25dfeaab61d2d326e6020aa3a8 /tests/tasty.hs
parent45083642667fce8a1f6d1491f3487243416e8cc0 (diff)
downloadgraphql-06b3302862e0c427439136241fb6299f215cec52.tar.gz
Add kitchen sink parse/encode unit test
This also includes the fixes to make it work. Golden tests have been removed.
Diffstat (limited to 'tests/tasty.hs')
-rw-r--r--tests/tasty.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/tasty.hs b/tests/tasty.hs
new file mode 100644
index 0000000..64786e6
--- /dev/null
+++ b/tests/tasty.hs
@@ -0,0 +1,23 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Main where
+
+import Data.Attoparsec.Text (parseOnly)
+import qualified Data.Text.IO as Text
+import Test.Tasty (defaultMain)
+import Test.Tasty.HUnit
+
+import qualified Data.GraphQL.Parser as Parser
+import qualified Data.GraphQL.Printer as Printer
+
+import Paths_graphql (getDataFileName)
+
+main :: IO ()
+main = defaultMain =<< testCase "Kitchen Sink"
+ <$> (assertEqual "Encode" <$> expected <*> actual)
+ where
+ expected = Text.readFile
+ =<< getDataFileName "tests/data/kitchen-sink.min.graphql"
+
+ actual = either (error "Parsing error!") Printer.document
+ <$> parseOnly Parser.document
+ <$> expected