graphql/tests/tasty.hs

37 lines
1.2 KiB
Haskell
Raw Normal View History

module Main where
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
)
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