graphql/tests/tasty.hs

37 lines
1.2 KiB
Haskell
Raw Normal View History

module Main where
2019-06-21 10:44:58 +02:00
import qualified Data.Text.IO as T.IO
import qualified Language.GraphQL.Encoder as Encoder
import qualified Language.GraphQL.LexerTest as LexerTest
import qualified Language.GraphQL.Parser as Parser
2019-06-21 10:44:58 +02:00
import Text.Megaparsec ( errorBundlePretty
, parse
)
import Test.Tasty ( TestTree
, defaultMain
, testGroup
)
import Test.Tasty.HUnit ( assertEqual
, assertFailure
, testCase
)
import Paths_graphql (getDataFileName)
2019-06-21 10:44:58 +02:00
import qualified Test.StarWars.QueryTests as SW
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
]
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
2019-06-21 10:44:58 +02:00
either
(assertFailure . errorBundlePretty)
(assertEqual "Encode" expected . Encoder.document)
$ parse Parser.document dataFileName expected