2022-06-03 11:06:31 +03:00
|
|
|
module Test.CapabilitiesSpec (spec) where
|
|
|
|
|
|
|
|
import Hasura.Backends.DataConnector.API (Capabilities, CapabilitiesResponse (..), Config, Routes (..), validateConfigAgainstConfigSchema)
|
|
|
|
import Servant.API (NamedRoutes)
|
|
|
|
import Servant.Client (Client, (//))
|
2022-08-04 04:00:48 +03:00
|
|
|
import Test.Expectations (jsonShouldBe)
|
2022-06-03 11:06:31 +03:00
|
|
|
import Test.Hspec (Spec, describe, it)
|
|
|
|
import Prelude
|
|
|
|
|
|
|
|
spec :: Client IO (NamedRoutes Routes) -> Config -> Capabilities -> Spec
|
|
|
|
spec api config expectedCapabilities = describe "capabilities API" $ do
|
|
|
|
it "returns the expected capabilities" $ do
|
|
|
|
CapabilitiesResponse capabilities _ <- api // _capabilities
|
2022-08-04 04:00:48 +03:00
|
|
|
capabilities `jsonShouldBe` expectedCapabilities
|
2022-06-03 11:06:31 +03:00
|
|
|
|
|
|
|
it "returns a schema that can be used to validate the current config" $ do
|
|
|
|
CapabilitiesResponse _ configSchema <- api // _capabilities
|
2022-08-04 04:00:48 +03:00
|
|
|
validateConfigAgainstConfigSchema configSchema config `jsonShouldBe` []
|