2022-04-10 07:47:15 +03:00
|
|
|
module Test.SchemaSpec (spec) where
|
|
|
|
|
|
|
|
import Data.List (sortOn)
|
2022-06-03 11:06:31 +03:00
|
|
|
import Hasura.Backends.DataConnector.API (Config, Routes (..), SchemaResponse (..), SourceName, TableInfo (..))
|
2022-04-10 07:47:15 +03:00
|
|
|
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
|
|
|
|
|
2022-06-03 11:06:31 +03:00
|
|
|
spec :: Client IO (NamedRoutes Routes) -> SourceName -> Config -> Spec
|
|
|
|
spec api sourceName config = describe "schema API" $ do
|
2022-04-10 07:47:15 +03:00
|
|
|
it "returns Chinook schema" $ do
|
2022-06-02 08:22:44 +03:00
|
|
|
tables <- (sortOn dtiName . srTables) <$> (api // _schema) sourceName config
|
2022-04-10 07:47:15 +03:00
|
|
|
tables `shouldBe` Data.schemaTables
|