mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-24 07:52:14 +03:00
58c44f55dd
GitOrigin-RevId: 1c8c4d60e033c8a0bc8b2beed24c5bceb7d4bcc8
24 lines
880 B
Haskell
24 lines
880 B
Haskell
module Hasura.RQL.MetadataSpec (spec) where
|
|
|
|
import Hasura.Prelude
|
|
|
|
import qualified Data.Aeson.Ordered as AO
|
|
|
|
import Data.Aeson (eitherDecodeStrict)
|
|
import Test.Hspec
|
|
import Test.QuickCheck
|
|
|
|
import Hasura.EncJSON
|
|
import Hasura.RQL.DDL.Metadata.Generator (genMetadata)
|
|
import Hasura.RQL.Types.Metadata (Metadata, metadataToOrdJSON)
|
|
|
|
spec :: Spec
|
|
spec = describe "metadataToOrdJSON" $ do
|
|
it "produces JSON that can be parsed by the FromJSON instance for Metadata" $
|
|
withMaxSuccess 20 $
|
|
forAll (resize 3 genMetadata) $ \metadata ->
|
|
let encodedString = encJToBS $ AO.toEncJSON $ metadataToOrdJSON metadata
|
|
in case eitherDecodeStrict @Metadata encodedString of
|
|
Left err -> counterexample err False
|
|
Right _ -> property True
|