mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 01:44:03 +03:00
f4ef0ddbdd
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5066 GitOrigin-RevId: f15a3309ccd5eb4e19eee0f4b59dccba2cd7fefa
26 lines
1.1 KiB
Haskell
26 lines
1.1 KiB
Haskell
module Test.SchemaSpec (spec) where
|
|
|
|
import Data.List (sortOn)
|
|
import Hasura.Backends.DataConnector.API (Config, Routes (..), SchemaResponse (..), SourceName, TableInfo (..))
|
|
import Hasura.Backends.DataConnector.API.V0.Column (ColumnInfo (..))
|
|
import Servant.API (NamedRoutes)
|
|
import Servant.Client (Client, (//))
|
|
import Test.Data qualified as Data
|
|
import Test.Hspec (Spec, describe, it)
|
|
import Test.Hspec.Expectations.Pretty (shouldBe)
|
|
import Prelude
|
|
|
|
removeDescriptionFromColumn :: ColumnInfo -> ColumnInfo
|
|
removeDescriptionFromColumn c = c {dciDescription = Nothing}
|
|
|
|
removeDescription :: TableInfo -> TableInfo
|
|
removeDescription t@TableInfo {dtiColumns} = t {dtiDescription = Nothing, dtiColumns = newColumns}
|
|
where
|
|
newColumns = map removeDescriptionFromColumn dtiColumns
|
|
|
|
spec :: Client IO (NamedRoutes Routes) -> SourceName -> Config -> Spec
|
|
spec api sourceName config = describe "schema API" $ do
|
|
it "returns Chinook schema" $ do
|
|
tables <- (map removeDescription . sortOn dtiName . srTables) <$> (api // _schema) sourceName config
|
|
tables `shouldBe` map removeDescription Data.schemaTables
|