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