mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-20 05:51:54 +03:00
84b84a78e1
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6433 GitOrigin-RevId: c5f5e0c2e25c6820d9f73a1e90699cf18dc4cd47
30 lines
990 B
Haskell
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]
|