graphql-engine/server/tests-gdw-api/Test/SchemaSpec.hs
Daniel Chambers 38c41b2ae6 GDW Agent Test Suite [GDW-79]
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4175
GitOrigin-RevId: d37d7d131597af6b9cca6bd773c8dbbce8719ca5
2022-04-10 04:48:30 +00:00

21 lines
790 B
Haskell

module Test.SchemaSpec (spec) where
import Data.List (sortOn)
import Hasura.Backends.DataWrapper.API (Capabilities, Routes (..), SchemaResponse (..), TableInfo (..))
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
spec :: Client IO (NamedRoutes Routes) -> Capabilities -> Spec
spec api expectedCapabilities = describe "schema API" $ do
it "returns the expected capabilities" $ do
capabilities <- fmap srCapabilities $ api // _schema
capabilities `shouldBe` expectedCapabilities
it "returns Chinook schema" $ do
tables <- fmap (sortOn dtiName . srTables) $ api // _schema
tables `shouldBe` Data.schemaTables