mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-19 21:41:44 +03:00
4a83bb1834
https://github.com/hasura/graphql-engine-mono/pull/1995 Co-authored-by: David Overton <7734777+dmoverton@users.noreply.github.com> GitOrigin-RevId: 178669089ec5e63b1f3da1d3ba0a9f8debbc108d
22 lines
830 B
Haskell
22 lines
830 B
Haskell
module Hasura.RQL.MetadataSpec (spec) where
|
|
|
|
import Hasura.Prelude
|
|
|
|
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 $ encJFromOrderedValue $ metadataToOrdJSON metadata
|
|
in case eitherDecodeStrict @Metadata encodedString of
|
|
Left err -> counterexample err False
|
|
Right _ -> property True
|