mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-20 22:11:45 +03:00
e6db044ecc
- One test suite wasn't getting picked up due to it not satisfying the [criteria](https://hspec.github.io/hspec-discover.html) for `hspec-discover` - One test was broken ever since it was introduced in hasura/graphql-engine-mono#5181. This wasn't picked up due to the module not satisfying `hspec-discover`'s criteria until more recently. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7801 GitOrigin-RevId: fd5c31ccf12d6d0c4be0dc7bf99f14d63caccc83
35 lines
1.4 KiB
Haskell
35 lines
1.4 KiB
Haskell
module Hasura.GraphQL.Parser.MonadParseSpec (spec) where
|
|
|
|
import Data.Aeson.Internal
|
|
import Hasura.Base.ErrorMessage
|
|
import Hasura.GraphQL.Parser.Class
|
|
import Hasura.GraphQL.Parser.ErrorCode
|
|
import Hasura.GraphQL.Parser.Monad
|
|
import Hasura.GraphQL.Parser.TestInstances ()
|
|
import Test.Hspec
|
|
|
|
runParse' :: Parse () -> Either ParseError ()
|
|
runParse' = runParse @_ @()
|
|
|
|
errorMessage :: ErrorMessage
|
|
errorMessage = "oh no"
|
|
|
|
spec :: Spec
|
|
spec = do
|
|
describe "parse error path" $ do
|
|
it "is empty when no keys added" $ do
|
|
let parser = parseError errorMessage
|
|
expected = ParseError {pePath = [], peMessage = errorMessage, peCode = ValidationFailed}
|
|
runParse' parser `shouldBe` Left expected
|
|
|
|
it "has two items in the order they were added" $ do
|
|
let parser = withKey (Key "dog") (withKey (Key "log") (parseError errorMessage))
|
|
expected = ParseError {pePath = [Key "dog", Key "log"], peMessage = errorMessage, peCode = ValidationFailed}
|
|
runParse' parser `shouldBe` Left expected
|
|
|
|
it "has multiple keys provisioned from a JSONPath" $ do
|
|
let path :: JSONPath = [Key "hi", Index 1, Key "foo bar"]
|
|
parser = withPath path (withKey (Key "first") (parseError errorMessage))
|
|
expected = ParseError {pePath = path <> [Key "first"], peMessage = errorMessage, peCode = ValidationFailed}
|
|
runParse' parser `shouldBe` Left expected
|