mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 21:12:09 +03:00
5c06eb7a3e
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5930 GitOrigin-RevId: 8c11387fa8556c3cdf8c92a0924ae53d31b953a5
53 lines
1.6 KiB
Haskell
53 lines
1.6 KiB
Haskell
{-# LANGUAGE OverloadedLists #-}
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
module Hasura.Backends.DataConnector.API.V0.ColumnSpec (spec, genColumnName, genColumnInfo) where
|
|
|
|
import Data.Aeson.QQ.Simple (aesonQQ)
|
|
import Hasura.Backends.DataConnector.API.V0
|
|
import Hasura.Backends.DataConnector.API.V0.ScalarSpec (genType)
|
|
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 "ColumnName" $ do
|
|
testToFromJSONToSchema (ColumnName "my_column_name") [aesonQQ|"my_column_name"|]
|
|
jsonOpenApiProperties genColumnName
|
|
describe "ColumnInfo" $ do
|
|
describe "without description" $
|
|
testToFromJSONToSchema
|
|
(ColumnInfo (ColumnName "my_column_name") StringTy False Nothing)
|
|
[aesonQQ|
|
|
{ "name": "my_column_name",
|
|
"type": "string",
|
|
"nullable": false
|
|
}
|
|
|]
|
|
describe "with description" $
|
|
testToFromJSONToSchema
|
|
(ColumnInfo (ColumnName "my_column_name") NumberTy True (Just "My column description"))
|
|
[aesonQQ|
|
|
{ "name": "my_column_name",
|
|
"type": "number",
|
|
"nullable": true,
|
|
"description": "My column description"
|
|
}
|
|
|]
|
|
jsonOpenApiProperties genColumnInfo
|
|
|
|
genColumnName :: MonadGen m => m ColumnName
|
|
genColumnName = ColumnName <$> genArbitraryAlphaNumText defaultRange
|
|
|
|
genColumnInfo :: MonadGen m => m ColumnInfo
|
|
genColumnInfo =
|
|
ColumnInfo
|
|
<$> genColumnName
|
|
<*> genType
|
|
<*> Gen.bool
|
|
<*> Gen.maybe (genArbitraryAlphaNumText defaultRange)
|