graphql-engine/server/src-test/Hasura/RQL/MetadataSpec.hs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
739 B
Haskell
Raw Normal View History

module Hasura.RQL.MetadataSpec (spec) where
import Data.Aeson (eitherDecodeStrict)
import Hasura.EncJSON
import Hasura.Prelude
import Hasura.RQL.DDL.Metadata.Generator (genMetadata)
import Hasura.RQL.Types.Metadata (Metadata, metadataToOrdJSON)
import Test.Hspec
import Test.QuickCheck
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