2019-11-18 21:45:54 +03:00
|
|
|
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
|
2020-01-11 07:05:07 +03:00
|
|
|
import Hasura.RQL.DDL.Metadata.Generator (genReplaceMetadata)
|
|
|
|
import Hasura.RQL.DDL.Metadata.Types (ReplaceMetadata, replaceMetadataToOrdJSON)
|
2019-11-18 21:45:54 +03:00
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = describe "replaceMetadataToOrdJSON" $ do
|
|
|
|
it "produces JSON that can be parsed by the ToJSON instance for ReplaceMetadata" $
|
2020-01-11 07:05:07 +03:00
|
|
|
withMaxSuccess 50 $
|
2019-11-18 21:45:54 +03:00
|
|
|
forAll (resize 3 genReplaceMetadata) $ \metadata ->
|
|
|
|
let encodedString = encJToBS $ AO.toEncJSON $ replaceMetadataToOrdJSON metadata
|
|
|
|
in case eitherDecodeStrict @ReplaceMetadata encodedString of
|
|
|
|
Left err -> counterexample err False
|
|
|
|
Right _ -> property True
|