2021-08-06 16:39:00 +03:00
|
|
|
module Hasura.RQL.MetadataSpec (spec) where
|
|
|
|
|
2021-09-24 01:56:37 +03:00
|
|
|
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
|
2021-08-06 16:39:00 +03:00
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = describe "metadataToOrdJSON" $ do
|
|
|
|
it "produces JSON that can be parsed by the FromJSON instance for Metadata" $
|
|
|
|
withMaxSuccess 20 $
|
2021-09-24 01:56:37 +03:00
|
|
|
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
|