graphql-engine/server/src-test/Hasura/Backends/DataConnector/API/V0/ScalarSpec.hs
2022-10-20 03:24:53 +00:00

30 lines
990 B
Haskell

{-# LANGUAGE QuasiQuotes #-}
module Hasura.Backends.DataConnector.API.V0.ScalarSpec (spec, genScalarType) where
import Data.Aeson.QQ.Simple (aesonQQ)
import Hasura.Backends.DataConnector.API.V0.Scalar
import Hasura.Generator.Common (defaultRange, genArbitraryAlphaNumText)
import Hasura.Prelude
import Hedgehog
import Hedgehog.Gen qualified as Gen
import Test.Aeson.Utils
import Test.Hspec
spec :: Spec
spec = do
describe "ScalarType" $ do
describe "StringTy" $
testToFromJSONToSchema StringTy [aesonQQ|"string"|]
describe "NumberTy" $
testToFromJSONToSchema NumberTy [aesonQQ|"number"|]
describe "BoolTy" $
testToFromJSONToSchema BoolTy [aesonQQ|"bool"|]
describe "CustomTy" $
testToFromJSONToSchema (CustomTy "foo") [aesonQQ|"foo"|]
jsonOpenApiProperties genScalarType
genScalarType :: MonadGen m => m ScalarType
genScalarType =
Gen.choice [pure StringTy, pure NumberTy, pure BoolTy, CustomTy <$> genArbitraryAlphaNumText defaultRange]