summaryrefslogtreecommitdiff
path: root/tests/Language/GraphQL/ErrorSpec.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2021-05-10 09:43:39 +0200
committerEugen Wissner <belka@caraus.de>2021-05-10 09:43:39 +0200
commit1af95345d21ecfaa0823cc5343d2ccc83c89d449 (patch)
tree1fc442bf20d116254a39c4ab17659d9e88dcfe68 /tests/Language/GraphQL/ErrorSpec.hs
parent0d23df3da29cfe0b78af922cea71db5fa1d5c98c (diff)
downloadgraphql-1af95345d21ecfaa0823cc5343d2ccc83c89d449.tar.gz
Deprecate internal error generation functions
The functions generating errors in the executor should be changed anyway when we provide better error messages from the executor, with the error location and response path. So public definitions of these functions are deprecated now and they are replaced by more generic functions in the executor code.
Diffstat (limited to 'tests/Language/GraphQL/ErrorSpec.hs')
-rw-r--r--tests/Language/GraphQL/ErrorSpec.hs34
1 files changed, 23 insertions, 11 deletions
diff --git a/tests/Language/GraphQL/ErrorSpec.hs b/tests/Language/GraphQL/ErrorSpec.hs
index 38d7d3a..f64e70a 100644
--- a/tests/Language/GraphQL/ErrorSpec.hs
+++ b/tests/Language/GraphQL/ErrorSpec.hs
@@ -8,17 +8,29 @@ module Language.GraphQL.ErrorSpec
) where
import qualified Data.Aeson as Aeson
-import qualified Data.Sequence as Seq
+import Data.List.NonEmpty (NonEmpty (..))
import Language.GraphQL.Error
-import Test.Hspec ( Spec
- , describe
- , it
- , shouldBe
- )
+import Test.Hspec
+ ( Spec
+ , describe
+ , it
+ , shouldBe
+ )
+import Text.Megaparsec (PosState(..))
+import Text.Megaparsec.Error (ParseError(..), ParseErrorBundle(..))
+import Text.Megaparsec.Pos (SourcePos(..), mkPos)
spec :: Spec
-spec = describe "singleError" $
- it "constructs an error with the given message" $
- let errors'' = Seq.singleton $ Error "Message." [] []
- expected = Response Aeson.Null errors''
- in singleError "Message." `shouldBe` expected
+spec = describe "parseError" $
+ it "generates response with a single error" $ do
+ let parseErrors = TrivialError 0 Nothing mempty :| []
+ posState = PosState
+ { pstateInput = ""
+ , pstateOffset = 0
+ , pstateSourcePos = SourcePos "" (mkPos 1) (mkPos 1)
+ , pstateTabWidth = mkPos 1
+ , pstateLinePrefix = ""
+ }
+ Response Aeson.Null actual <-
+ parseError (ParseErrorBundle parseErrors posState)
+ length actual `shouldBe` 1