2015-09-22 13:53:37 +02:00
|
|
|
module Main where
|
|
|
|
|
2015-09-22 14:23:18 +02:00
|
|
|
import qualified Data.GraphQL.Encoder as Encoder
|
2019-06-21 10:44:58 +02:00
|
|
|
import qualified Language.GraphQL.LexerTest as LexerTest
|
|
|
|
import qualified Data.GraphQL.Parser as Parser
|
|
|
|
import qualified Data.Text.IO as T.IO
|
|
|
|
import Text.Megaparsec ( errorBundlePretty
|
|
|
|
, parse
|
|
|
|
)
|
|
|
|
import Test.Tasty ( TestTree
|
|
|
|
, defaultMain
|
|
|
|
, testGroup
|
|
|
|
)
|
|
|
|
import Test.Tasty.HUnit ( assertEqual
|
|
|
|
, assertFailure
|
|
|
|
, testCase
|
|
|
|
)
|
2015-09-22 13:53:37 +02:00
|
|
|
import Paths_graphql (getDataFileName)
|
2019-06-21 10:44:58 +02:00
|
|
|
import qualified Test.StarWars.QueryTests as SW
|
2015-09-22 13:53:37 +02:00
|
|
|
|
|
|
|
main :: IO ()
|
2019-06-21 10:44:58 +02:00
|
|
|
main = defaultMain $ testGroup "Tests"
|
|
|
|
[ testGroup "Reference tests" [LexerTest.reference, SW.test]
|
|
|
|
, testGroup "Implementation tests" [LexerTest.implementation]
|
|
|
|
, kitchenTest
|
|
|
|
]
|
2015-10-19 12:19:39 +02:00
|
|
|
|
2019-06-21 10:44:58 +02:00
|
|
|
kitchenTest :: TestTree
|
|
|
|
kitchenTest = testCase "Kitchen Sink" $ do
|
|
|
|
dataFileName <- getDataFileName "tests/data/kitchen-sink.min.graphql"
|
|
|
|
expected <- T.IO.readFile dataFileName
|
2015-09-22 13:53:37 +02:00
|
|
|
|
2019-06-21 10:44:58 +02:00
|
|
|
either
|
|
|
|
(assertFailure . errorBundlePretty)
|
|
|
|
(assertEqual "Encode" expected . Encoder.document)
|
|
|
|
$ parse Parser.document dataFileName expected
|