2015-09-22 14:02:12 +02:00
|
|
|
{-# LANGUAGE CPP #-}
|
2015-09-22 13:53:37 +02:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Main where
|
|
|
|
|
2015-09-22 14:02:12 +02:00
|
|
|
#if !MIN_VERSION_base(4,8,0)
|
|
|
|
import Control.Applicative ((<$>), (<*>))
|
|
|
|
#endif
|
|
|
|
|
2015-09-22 13:53:37 +02:00
|
|
|
import Data.Attoparsec.Text (parseOnly)
|
|
|
|
import qualified Data.Text.IO as Text
|
2015-10-19 12:19:39 +02:00
|
|
|
import Test.Tasty (TestTree, defaultMain, testGroup)
|
2015-09-22 13:53:37 +02:00
|
|
|
import Test.Tasty.HUnit
|
|
|
|
|
|
|
|
import qualified Data.GraphQL.Parser as Parser
|
2015-09-22 14:23:18 +02:00
|
|
|
import qualified Data.GraphQL.Encoder as Encoder
|
2015-09-22 13:53:37 +02:00
|
|
|
|
2016-02-12 13:27:46 +01:00
|
|
|
import qualified Test.StarWars.QueryTests as SW
|
2015-09-22 13:53:37 +02:00
|
|
|
import Paths_graphql (getDataFileName)
|
|
|
|
|
|
|
|
main :: IO ()
|
2017-01-28 18:15:14 +01:00
|
|
|
main = defaultMain . testGroup "Tests" . (: [SW.test]) =<< kitchenTest
|
2015-10-19 12:19:39 +02:00
|
|
|
|
2017-01-28 18:15:14 +01:00
|
|
|
kitchenTest :: IO TestTree
|
|
|
|
kitchenTest = testCase "Kitchen Sink"
|
2016-12-18 16:19:59 +01:00
|
|
|
<$> (assertEqual "Encode" <$> expected <*> actual)
|
2015-09-22 13:53:37 +02:00
|
|
|
where
|
|
|
|
expected = Text.readFile
|
|
|
|
=<< getDataFileName "tests/data/kitchen-sink.min.graphql"
|
|
|
|
|
2015-09-22 14:23:18 +02:00
|
|
|
actual = either (error "Parsing error!") Encoder.document
|
2016-01-26 13:38:02 +01:00
|
|
|
. parseOnly Parser.document
|
2015-09-22 13:53:37 +02:00
|
|
|
<$> expected
|