mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-20 14:01:39 +03:00
d54bb30d3b
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6061 Co-authored-by: Vishnu Bharathi <4211715+scriptnull@users.noreply.github.com> GitOrigin-RevId: 855d96378030f4e01b0c74b00e20e592e51e7a49
23 lines
1.2 KiB
Haskell
23 lines
1.2 KiB
Haskell
module Test.CapabilitiesSpec (spec) where
|
|
|
|
import Hasura.Backends.DataConnector.API (Capabilities, CapabilitiesResponse (..), Config, Routes (..), capabilitiesCase, validateConfigAgainstConfigSchema)
|
|
import Servant.API (NamedRoutes)
|
|
import Servant.Client (Client, (//))
|
|
import Test.Expectations (jsonShouldBe)
|
|
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 {..} <- capabilitiesGuard =<< (api // _capabilities)
|
|
_crCapabilities `jsonShouldBe` expectedCapabilities
|
|
|
|
it "returns a schema that can be used to validate the current config" $ do
|
|
CapabilitiesResponse {..} <- capabilitiesGuard =<< (api // _capabilities)
|
|
validateConfigAgainstConfigSchema _crConfigSchemaResponse config `jsonShouldBe` []
|
|
where
|
|
defaultAction = fail "Unexpected data connector capabilities response - Unexpected Type"
|
|
errorAction e = fail $ "Unexpected data connector capabilities error response: " <> show e
|
|
capabilitiesGuard = capabilitiesCase defaultAction (pure) errorAction
|