mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-21 22:41:43 +03:00
e4da80421e
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4815 GitOrigin-RevId: d0d889754944cc8270bdee2fd21b0cf5dcad9175
28 lines
874 B
Haskell
28 lines
874 B
Haskell
module Hasura.GraphQL.Parser.MonadParseTest (spec) where
|
|
|
|
import Data.Aeson.Internal
|
|
import Hasura.Base.Error
|
|
import Hasura.GraphQL.Parser.Class.Parse
|
|
import Hasura.GraphQL.Parser.Monad
|
|
import Hasura.Prelude
|
|
import Test.Hspec
|
|
|
|
runParse' :: Parse () -> Either QErr ()
|
|
runParse' = runParse @_ @()
|
|
|
|
errorStr :: Text
|
|
errorStr = "oh no"
|
|
|
|
spec :: Spec
|
|
spec = do
|
|
describe "withKey" $ do
|
|
it "Path is empty when no keys added" $ do
|
|
let parser = parseError errorStr
|
|
expected = (err400 ValidationFailed errorStr) {qePath = mempty}
|
|
runParse' parser `shouldBe` Left expected
|
|
|
|
it "Path has two items in the order they were added" $ do
|
|
let parser = withKey (Key "dog") (withKey (Key "log") (parseError errorStr))
|
|
expected = (err400 ValidationFailed errorStr) {qePath = [Key "dog", Key "log"]}
|
|
runParse' parser `shouldBe` Left expected
|