From ee0e0c3d1f1c259555d246df1be1c9e5b9be0e35 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Wed, 16 Sep 2015 10:12:36 +0200 Subject: [PATCH] Use Cabal data-files to access golden tests data Fixes #1. --- graphql.cabal | 2 ++ tests/golden.hs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/graphql.cabal b/graphql.cabal index 2f83aeb..d19731c 100644 --- a/graphql.cabal +++ b/graphql.cabal @@ -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 diff --git a/tests/golden.hs b/tests/golden.hs index e7ab70f..2323a97 100644 --- a/tests/golden.hs +++ b/tests/golden.hs @@ -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) -