Use Cabal data-files to access golden tests data

Fixes #1.
This commit is contained in:
Danny Navarro 2015-09-16 10:12:36 +02:00
parent 82a380079c
commit ee0e0c3d1f
2 changed files with 6 additions and 4 deletions

View File

@ -16,6 +16,8 @@ build-type: Simple
cabal-version: >=1.10
tested-with: GHC == 7.10
extra-source-files: README.md CHANGELOG.md stack.yaml
data-files: tests/data/*.graphql
tests/data/*.graphql.golden
library
default-language: Haskell2010

View File

@ -8,14 +8,14 @@ import qualified Data.Text.IO as TIO
import Test.Tasty (defaultMain)
import Test.Tasty.Golden (goldenVsString)
import Paths_graphql (getDataFileName)
import Data.GraphQL.Parser (document)
main :: IO ()
main = defaultMain
$ goldenVsString "kitchen-sink.graphql"
"./tests/data/kitchen-sink.graphql.golden"
(parse "./tests/data/kitchen-sink.graphql")
=<< goldenVsString "kitchen-sink.graphql"
<$> getDataFileName "tests/data/kitchen-sink.graphql.graphql.golden"
<*> (parse <$> getDataFileName "tests/data/kitchen-sink.graphql")
where
parse = fmap (parseOnly document) . TIO.readFile
>=> pure . either B8.pack (flip B8.snoc '\n' . B8.pack . show)