2022-09-21 21:01:48 +03:00
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
2022-10-20 15:45:31 +03:00
|
|
|
{-# LANGUAGE TypeApplications #-}
|
2022-09-21 21:01:48 +03:00
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
module Hasura.Server.Init.ArgSpec
|
|
|
|
( spec,
|
|
|
|
)
|
|
|
|
where
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2022-07-17 05:04:04 +03:00
|
|
|
import Control.Lens (preview, _Just)
|
2022-10-20 15:45:31 +03:00
|
|
|
import Data.Aeson qualified as Aeson
|
2022-08-05 03:28:49 +03:00
|
|
|
import Data.HashSet qualified as Set
|
2022-09-21 21:01:48 +03:00
|
|
|
import Data.Time (NominalDiffTime)
|
2022-07-17 05:04:04 +03:00
|
|
|
import Data.URL.Template qualified as Template
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
import Database.PG.Query qualified as PG
|
2022-07-15 08:03:02 +03:00
|
|
|
import Hasura.GraphQL.Execute.Subscription.Options qualified as ES
|
|
|
|
import Hasura.GraphQL.Schema.NamingCase qualified as NC
|
2022-07-29 03:45:51 +03:00
|
|
|
import Hasura.GraphQL.Schema.Options qualified as Options
|
2022-07-15 08:03:02 +03:00
|
|
|
import Hasura.Logging qualified as Logging
|
|
|
|
import Hasura.Prelude
|
2022-10-20 15:45:31 +03:00
|
|
|
import Hasura.RQL.Types.Metadata (Metadata, MetadataDefaults (..), overrideMetadataDefaults, _metaBackendConfigs)
|
|
|
|
import Hasura.SQL.BackendMap qualified as BackendMap
|
2022-07-15 08:03:02 +03:00
|
|
|
import Hasura.Server.Auth qualified as Auth
|
|
|
|
import Hasura.Server.Cors qualified as Cors
|
|
|
|
import Hasura.Server.Init qualified as UUT
|
2022-07-29 03:45:51 +03:00
|
|
|
import Hasura.Server.Logging qualified as Logging
|
2022-07-15 08:03:02 +03:00
|
|
|
import Hasura.Server.Types qualified as Types
|
|
|
|
import Hasura.Session qualified as Session
|
|
|
|
import Options.Applicative qualified as Opt
|
2022-09-21 21:01:48 +03:00
|
|
|
import Refined (NonNegative, Positive, refineTH)
|
2022-07-15 08:03:02 +03:00
|
|
|
import Test.Hspec qualified as Hspec
|
|
|
|
|
2022-07-19 01:12:24 +03:00
|
|
|
{-# ANN module ("HLint: ignore Redundant ==" :: String) #-}
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
spec :: Hspec.Spec
|
|
|
|
spec = Hspec.describe "Arg Parsing Tests" $ do
|
|
|
|
mainParserSpec
|
|
|
|
downgradeParserSpec
|
|
|
|
serveParserSpec
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
mainParserSpec :: Hspec.Spec
|
|
|
|
mainParserSpec =
|
|
|
|
Hspec.describe "Main Command" $ do
|
2022-07-17 05:04:04 +03:00
|
|
|
Hspec.it "Accepts '--database-url'" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--database-url", "postgres://user:password@localhost/hasura", "serve", "--server-port", "420"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _do -> pure ()
|
|
|
|
Opt.Failure pf -> Hspec.expectationFailure $ show pf
|
|
|
|
Opt.CompletionInvoked _cr -> Hspec.expectationFailure "Completion Invoked"
|
|
|
|
|
|
|
|
Hspec.it "Rejects '--database-url' requires an argument" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--database-url", "serve", "--server-port", "420"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "Accepts '--database-url' with a valid URLTemplate argument" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--database-url", "https://hasura.io/{{foo}}", "serve", "--server-port", "420"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
2022-07-22 02:35:50 +03:00
|
|
|
fmap (preview (UUT.horDatabaseUrl . UUT.pciDatabaseConn . _Just . UUT._PGConnDatabaseUrl)) result `Hspec.shouldSatisfy` \case
|
2022-07-17 05:04:04 +03:00
|
|
|
Opt.Success template -> template == eitherToMaybe (Template.parseURLTemplate "https://hasura.io/{{foo}}")
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
2022-08-01 22:35:13 +03:00
|
|
|
Hspec.it "Accepts PostgressConnDetailsRaw flags" $ do
|
2022-07-17 05:04:04 +03:00
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput =
|
|
|
|
[ "--host",
|
|
|
|
"localhost",
|
|
|
|
"--port",
|
|
|
|
"22",
|
|
|
|
"--user",
|
|
|
|
"user",
|
|
|
|
"--password",
|
|
|
|
"pass",
|
|
|
|
"--dbname",
|
|
|
|
"hasura",
|
|
|
|
"serve",
|
|
|
|
"--server-port",
|
|
|
|
"420"
|
|
|
|
]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
2022-07-22 02:35:50 +03:00
|
|
|
fmap (preview (UUT.horDatabaseUrl . UUT.pciDatabaseConn . _Just . UUT._PGConnDetails)) result `Hspec.shouldSatisfy` \case
|
2022-07-17 05:04:04 +03:00
|
|
|
Opt.Success template ->
|
|
|
|
template
|
|
|
|
== Just
|
2022-08-01 22:35:13 +03:00
|
|
|
( UUT.PostgresConnDetailsRaw
|
2022-07-17 05:04:04 +03:00
|
|
|
{ connHost = "localhost",
|
|
|
|
connPort = 22,
|
|
|
|
connUser = "user",
|
|
|
|
connPassword = "pass",
|
|
|
|
connDatabase = "hasura",
|
|
|
|
connOptions = Nothing
|
|
|
|
}
|
|
|
|
)
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "Accepts '--metadata-database-url'" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--metadata-database-url", "postgres://user:password@localhost/hasura", "serve", "--server-port", "420"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
2022-07-22 02:35:50 +03:00
|
|
|
fmap UUT._horMetadataDbUrl result `Hspec.shouldSatisfy` \case
|
2022-07-17 05:04:04 +03:00
|
|
|
Opt.Success metadataUrl -> metadataUrl == Just "postgres://user:password@localhost/hasura"
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "Accepts the serve command" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["serve", "--server-port", "420"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
case result of
|
|
|
|
Opt.Success _do -> pure ()
|
|
|
|
Opt.Failure pf -> Hspec.expectationFailure $ show pf
|
|
|
|
Opt.CompletionInvoked _cr -> Hspec.expectationFailure "Completion Invoked"
|
|
|
|
|
|
|
|
Hspec.it "Accepts the export command" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["export"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
case result of
|
|
|
|
Opt.Success _do -> pure ()
|
|
|
|
Opt.Failure pf -> Hspec.expectationFailure $ show pf
|
|
|
|
Opt.CompletionInvoked _cr -> Hspec.expectationFailure "Completion Invoked"
|
|
|
|
|
|
|
|
Hspec.it "Accepts the clean command" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["clean"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
case result of
|
|
|
|
Opt.Success _do -> pure ()
|
|
|
|
Opt.Failure pf -> Hspec.expectationFailure $ show pf
|
|
|
|
Opt.CompletionInvoked _cr -> Hspec.expectationFailure "Completion Invoked"
|
|
|
|
|
|
|
|
Hspec.it "Accepts the downgrade command" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["downgrade", "--to-v1.0.0-beta.1", "--dryRun"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
case result of
|
|
|
|
Opt.Success _do -> pure ()
|
|
|
|
Opt.Failure pf -> Hspec.expectationFailure $ show pf
|
|
|
|
Opt.CompletionInvoked _cr -> Hspec.expectationFailure "Completion Invoked"
|
|
|
|
|
|
|
|
Hspec.it "Accepts the version command" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.parseHgeOpts @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["version"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
case result of
|
|
|
|
Opt.Success _do -> pure ()
|
|
|
|
Opt.Failure pf -> Hspec.expectationFailure $ show pf
|
|
|
|
Opt.CompletionInvoked _cr -> Hspec.expectationFailure "Completion Invoked"
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
downgradeParserSpec :: Hspec.Spec
|
|
|
|
downgradeParserSpec =
|
|
|
|
Hspec.describe "Downgrade Command" $ do
|
|
|
|
Hspec.it "It accepts '--to-catalog-version'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.downgradeCommandParser Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--to-catalog-version", "v2.8.2"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success do' -> do' == UUT.DowngradeOptions "v2.8.2" False
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--to-catalog-version' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.downgradeCommandParser Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--to-catalog-version"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--dry-run' with '--to-catalog-version'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.downgradeCommandParser Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--to-catalog-version", "v2.8.2", "--dryRun"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success do' -> do' == UUT.DowngradeOptions "v2.8.2" True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--dry-run' with a downgrade shortcut" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.downgradeCommandParser Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--to-v1.0.0-beta.1", "--dryRun"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success do' -> do' == UUT.DowngradeOptions "16" True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--dry-run' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.downgradeCommandParser Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--to-catalog-version", "v2.8.2", "--dryRun", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--dry-run' must be run with '--to-catalog-version' or a downgrade shortcut" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.downgradeCommandParser Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--dryRun"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts a downgrade shortcut" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.downgradeCommandParser Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--to-v1.0.0-beta.1"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success do' -> do' == UUT.DowngradeOptions "16" False
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails downgrade shortcuts dont expect arguments" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.downgradeCommandParser Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--to-v1.0.0-beta.1", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
serveParserSpec :: Hspec.Spec
|
|
|
|
serveParserSpec =
|
|
|
|
Hspec.describe "Serve Command" $ do
|
|
|
|
Hspec.it "It accepts '--server-port'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--server-port", "420"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoPort result `Hspec.shouldSatisfy` \case
|
2022-08-17 04:07:44 +03:00
|
|
|
Opt.Success port -> port == Just (UUT.unsafePort 420)
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--server-port' 0" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--server-port", "0"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoPort result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success port -> port == Just (UUT.unsafePort 0)
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--server-port' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--server-port"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--server-port' expects an integer" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--server-port", "four"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
Hspec.it "It fails '--server-port' fails on a negative integer" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--server-port", "-1"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--server-port' fails on > 65535" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--server-port", "65536"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It accepts '--server-host'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--server-host", "*"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoHost result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success host -> host == Just "*"
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--server-host' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--server-host"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-08-01 22:35:13 +03:00
|
|
|
Hspec.it "It accepts the flags for a 'ConnParamsRaw'" $ do
|
2022-07-15 08:03:02 +03:00
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--stripes", "3", "--connections", "2", "--timeout", "40", "--conn-lifetime", "400", "--use-prepared-statements", "true", "--pool-timeout", "45"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoConnParams result `Hspec.shouldSatisfy` \case
|
2022-08-17 04:07:44 +03:00
|
|
|
Opt.Success rawConnParams ->
|
|
|
|
rawConnParams
|
|
|
|
== UUT.ConnParamsRaw
|
2022-09-21 21:01:48 +03:00
|
|
|
{ rcpStripes = Just $$(refineTH @NonNegative @Int 3),
|
|
|
|
rcpConns = Just $$(refineTH @NonNegative @Int 2),
|
|
|
|
rcpIdleTime = Just $$(refineTH @NonNegative @Int 40),
|
|
|
|
rcpConnLifetime = Just $$(refineTH @NonNegative @NominalDiffTime 400),
|
2022-08-17 04:07:44 +03:00
|
|
|
rcpAllowPrepare = Just True,
|
2022-09-21 21:01:48 +03:00
|
|
|
rcpPoolTimeout = Just $$(refineTH @NonNegative @NominalDiffTime 45)
|
2022-08-17 04:07:44 +03:00
|
|
|
}
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
Hspec.it "It fails '--stripes' must be a non-negative integer" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--stripes", "-3", "--connections", "2", "--timeout", "40", "--conn-lifetime", "400", "--use-prepared-statements", "true", "--pool-timeout", "45"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--connections' must be a non-negative integer" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--stripes", "3", "--connections", "-2", "--timeout", "40", "--conn-lifetime", "400", "--use-prepared-statements", "true", "--pool-timeout", "45"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--timeout' must be a non-negative integer" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--stripes", "3", "--connections", "2", "--timeout", "-40", "--conn-lifetime", "400", "--use-prepared-statements", "true", "--pool-timeout", "45"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--conn-lifetime' must be a non-negative integer" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--stripes", "3", "--connections", "2", "--timeout", "40", "--conn-lifetime", "-400", "--use-prepared-statements", "true", "--pool-timeout", "45"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--pool-timeout' must be a non-negative integer" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--stripes", "3", "--connections", "2", "--timeout", "40", "--conn-lifetime", "400", "--use-prepared-statements", "true", "--pool-timeout", "-45"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It accepts '--tx-iso'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--tx-iso", "read-committed"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoTxIso result `Hspec.shouldSatisfy` \case
|
Import `pg-client-hs` as `PG`
Result of executing the following commands:
```shell
# replace "as Q" imports with "as PG" (in retrospect this didn't need a regex)
git grep -lE 'as Q($|[^a-zA-Z])' -- '*.hs' | xargs sed -i -E 's/as Q($|[^a-zA-Z])/as PG\1/'
# replace " Q." with " PG."
git grep -lE ' Q\.' -- '*.hs' | xargs sed -i 's/ Q\./ PG./g'
# replace "(Q." with "(PG."
git grep -lE '\(Q\.' -- '*.hs' | xargs sed -i 's/(Q\./(PG./g'
# ditto, but for [, |, { and !
git grep -lE '\[Q\.' -- '*.hs' | xargs sed -i 's/\[Q\./\[PG./g'
git grep -l '|Q\.' -- '*.hs' | xargs sed -i 's/|Q\./|PG./g'
git grep -l '{Q\.' -- '*.hs' | xargs sed -i 's/{Q\./{PG./g'
git grep -l '!Q\.' -- '*.hs' | xargs sed -i 's/!Q\./!PG./g'
```
(Doing the `grep -l` before the `sed`, instead of `sed` on the entire codebase, reduces the number of `mtime` updates, and so reduces how many times a file gets recompiled while checking intermediate results.)
Finally, I manually removed a broken and unused `Arbitrary` instance in `Hasura.RQL.Network`. (It used an `import Test.QuickCheck.Arbitrary as Q` statement, which was erroneously caught by the first find-replace command.)
After this PR, `Q` is no longer used as an import qualifier. That was not the goal of this PR, but perhaps it's a useful fact for future efforts.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5933
GitOrigin-RevId: 8c84c59d57789111d40f5d3322c5a885dcfbf40e
2022-09-20 22:54:43 +03:00
|
|
|
Opt.Success txIso -> txIso == Just PG.ReadCommitted
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--tx-iso' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--tx-iso"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--tx-iso' expects valid TX isolation levels" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--tx-iso", "foo"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--admin-secret'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--admin-secret", "A monad is a monoid in the category of endofunctors"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoAdminSecret result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success adminSecret -> adminSecret == Just (Auth.hashAdminSecret "A monad is a monoid in the category of endofunctors")
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--admin-secret' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--admin-secret"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--access-key'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--access-key", "A monad is a monoid in the category of endofunctors"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoAdminSecret result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success adminSecret -> adminSecret == Just (Auth.hashAdminSecret "A monad is a monoid in the category of endofunctors")
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--access-key' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--access-key"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 11:54:27 +03:00
|
|
|
Hspec.it "It fails '--admin-secret' and '--access-key' cannot be used in conjunction" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--admin-secret", "A monad is a monoid in the category of endofunctors", "--access-key", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It accepts '--auth-hook'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--auth-hook", "http://www.auth.com"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
2022-08-04 05:24:35 +03:00
|
|
|
fmap (UUT.ahrUrl . UUT.rsoAuthHook) result `Hspec.shouldSatisfy` \case
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Success ahUrl -> ahUrl == Just "http://www.auth.com"
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--auth-hook' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--auth-hook"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--auth-hook-mode'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--auth-hook-mode", "POST"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
2022-08-04 05:24:35 +03:00
|
|
|
fmap (UUT.ahrType . UUT.rsoAuthHook) result `Hspec.shouldSatisfy` \case
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Success ahType -> ahType == Just Auth.AHTPost
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--auth-hook-mode' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--auth-hook-mode"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--auth-hook-mode' only expects GET or POST" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--auth-hook-mode", "PUT"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--jwt-secret'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--jwt-secret", "{ \"jwk_url\": \"https://www.hasura.io\", \"issuer\": \"myapp\" }"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoJwtSecret result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success jwtSecret -> jwtSecret == either (const Nothing) Just (readJson "{ \"jwk_url\": \"https://www.hasura.io\", \"issuer\": \"myapp\" }")
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--jwt-secret' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--jwt-secret"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--jwt-secret' expects a JSON serialized 'JWTConfig' object" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--jwt-secret", "{ \"name\": \"Simon\", \"issuer\": \"myapp\" }"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--unauthorized-role'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--unauthorized-role", "guest"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoUnAuthRole result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success unAuthRole -> fmap Session.roleNameToTxt unAuthRole == Just "guest"
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--unauthorized-role' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--unauthorized-role"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--cors-domain'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--cors-domain", "https://*.foo.bar.com:8080, http://*.localhost, http://localhost:3000, http://example.com"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoCorsConfig result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success corsConfig ->
|
|
|
|
corsConfig == eitherToMaybe (Cors.readCorsDomains "https://*.foo.bar.com:8080, http://*.localhost, http://localhost:3000, http://example.com")
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--cors-domain' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--cors-domain"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--cors-domain' rejects an invalid CORS domains" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--cors-domain", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--disable-cors'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--disable-cors"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoCorsConfig result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success corsConfig -> corsConfig == Just (Cors.CCDisabled False)
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--disable-cors' supercedes '--cors-domain'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--cors-domain", "https://*.foo.bar.com:8080, http://*.localhost, http://localhost:3000, http://example.com", "--disable-cors"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoCorsConfig result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success corsConfig -> corsConfig == Just (Cors.CCDisabled False)
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--disable-cors' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--disable-cors", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--enable-console'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-console"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEnableConsole result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success enableConsole -> enableConsole == True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enable-console' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-console", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--console-assets-dir'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--console-assets-dir", "/assets"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoConsoleAssetsDir result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success consoleAssetsDir -> consoleAssetsDir == Just "/assets"
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--console-assets-dir' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--console-assets-dir"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-09-27 17:50:32 +03:00
|
|
|
Hspec.it "It accepts '--console-sentry-dsn'" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--console-sentry-dsn", "123123"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoConsoleSentryDsn result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success consoleSentryDsn -> consoleSentryDsn == Just "123123"
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--console-sentry-dsn' expects an argument" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--console-sentry-dsn"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It accepts '--enable-telemetry'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-telemetry", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEnableTelemetry result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success enableTelemetry -> enableTelemetry == Just True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enable-telemetry' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-telemetry"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enable-telemetry' expects a boolean argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-telemetry", "one"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--ws-read-cookie'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--ws-read-cookie"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoWsReadCookie result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success wsReadCookie -> wsReadCookie == True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--ws-read-cookie' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--ws-read-cookie", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--stringify-numeric-types'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--stringify-numeric-types"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoStringifyNum result `Hspec.shouldSatisfy` \case
|
2022-07-29 03:45:51 +03:00
|
|
|
Opt.Success stringifyNum -> stringifyNum == Options.StringifyNumbers
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--stringify-numeric-types' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--stringify-numeric-types", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--v1-boolean-null-collapse'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--v1-boolean-null-collapse", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoDangerousBooleanCollapse result `Hspec.shouldSatisfy` \case
|
2022-08-26 07:37:35 +03:00
|
|
|
Opt.Success dangerousBooleanCollapse -> dangerousBooleanCollapse == Just Options.DangerouslyCollapseBooleans
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--v1-boolean-null-collapse' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--v1-boolean-null-collapse"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--v1-boolean-null-collapse' expects a boolean argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--v1-boolean-null-collapse", "123"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--enabled-apis'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enabled-apis", "graphql,pgdump"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEnabledAPIs result `Hspec.shouldSatisfy` \case
|
2022-08-05 03:28:49 +03:00
|
|
|
Opt.Success enabledAPIs -> enabledAPIs == Just (Set.fromList [UUT.GRAPHQL, UUT.PGDUMP])
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enabled-apis' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enabled-apis"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enabled-apis' expects a valid API arguments" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enabled-apis", "PIZZA"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--live-queries-multiplexed-refetch-interval'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--live-queries-multiplexed-refetch-interval", "54000"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoMxRefetchInt result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success mxRefetchInt -> mxRefetchInt == ES.mkRefetchInterval 54
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--live-queries-multiplexed-refetch-interval' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--live-queries-multiplexed-refetch-interval"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--live-queries-multiplexed-refetch-interval' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--live-queries-multiplexed-refetch-interval", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--live-queries-multiplexed-batch-size'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--live-queries-multiplexed-batch-size", "102"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoMxBatchSize result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success mxBatchSize -> mxBatchSize == ES.mkBatchSize 102
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--live-queries-multiplexed-batch-size' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--live-queries-multiplexed-batch-size"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--live-queries-multiplexed-batch-size' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--live-queries-multiplexed-batch-size", "false"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--streaming-queries-multiplexed-refetch-interval'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--streaming-queries-multiplexed-refetch-interval", "57000"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoStreamingMxRefetchInt result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success streamingMxRefetchInt -> streamingMxRefetchInt == ES.mkRefetchInterval 57
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--streaming-queries-multiplexed-refetch-interval' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--streaming-queries-multiplexed-refetch-interval"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--streaming-queries-multiplexed-refetch-interval' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--streaming-queries-multiplexed-refetch-interval", "foo"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--streaming-queries-multiplexed-batch-size'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--streaming-queries-multiplexed-batch-size", "102"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoStreamingMxBatchSize result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success streamingMxBatchSize -> streamingMxBatchSize == ES.mkBatchSize 102
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--streaming-queries-multiplexed-batch-size' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--streaming-queries-multiplexed-batch-size"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--streaming-queries-multiplexed-batch-size' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--streaming-queries-multiplexed-batch-size", "102.5"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--enable-allowlist'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-allowlist"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEnableAllowlist result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success enableAllowList -> enableAllowList == True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enable-allowlist' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-allowlist", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--enabled-log-types'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enabled-log-types", "startup, webhook-log"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEnabledLogTypes result `Hspec.shouldSatisfy` \case
|
2022-08-05 03:28:49 +03:00
|
|
|
Opt.Success enabledLogTypes -> enabledLogTypes == Just (Set.fromList [Logging.ELTStartup, Logging.ELTWebhookLog])
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enabled-log-types' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enabled-log-types"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enabled-log-types' expects a valid log types as arguments" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enabled-log-types", "not-valid-log-type, startup"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--log-level'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--log-level", "warn"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoLogLevel result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success logLevel -> logLevel == Just Logging.LevelWarn
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--log-level' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--log-level"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--log-level' expects a valid log level argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--log-level", "shout"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--query-plan-cache-size'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--query-plan-cache-size", "65535"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
-- NOTE: This is deprecated flag whose value is dropped
|
|
|
|
Opt.Success _logLevel -> True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--query-plan-cache-size' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--query-plan-cache-size"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--query-plan-cache-size' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--query-plan-cache-size", "false"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--dev-mode'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--dev-mode"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoDevMode result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success devMode -> devMode == True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--dev-mode' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--dev-mode", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--admin-internal-errors'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--admin-internal-errors", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoAdminInternalErrors result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success adminInternalErrors -> adminInternalErrors == Just True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--admin-internal-errors' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--admin-internal-errors"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--admin-internal-errors' expects a boolean argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--admin-internal-errors", "five"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--events-http-pool-size'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--events-http-pool-size", "50"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEventsHttpPoolSize result `Hspec.shouldSatisfy` \case
|
2022-09-21 21:01:48 +03:00
|
|
|
Opt.Success eventsHttpPoolSize -> eventsHttpPoolSize == Just $$(refineTH @Positive @Int 50)
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--events-http-pool-size' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--events-http-pool-size"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--events-http-pool-size' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--events-http-pool-size", "10.5"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--events-fetch-interval'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--events-fetch-interval", "634"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEventsFetchInterval result `Hspec.shouldSatisfy` \case
|
2022-09-21 21:01:48 +03:00
|
|
|
Opt.Success eventsFetchInterval -> eventsFetchInterval == Just $$(refineTH @NonNegative @Milliseconds 634)
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--events-fetch-interval' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--events-fetch-interval"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--events-fetch-interval' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--events-fetch-interval", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
Hspec.it "It fails '--events-fetch-interval' expects an non-negative integer" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--events-fetch-interval", "-10"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It accepts '--async-actions-fetch-interval'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--async-actions-fetch-interval", "123"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoAsyncActionsFetchInterval result `Hspec.shouldSatisfy` \case
|
2022-09-21 21:01:48 +03:00
|
|
|
Opt.Success asyncActionsFetchInterval -> asyncActionsFetchInterval == Just (UUT.Interval $$(refineTH 123))
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--async-actions-fetch-interval' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--async-actions-fetch-interval"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--async-actions-fetch-interval' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--async-actions-fetch-interval", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
Hspec.it "It fails '--async-actions-fetch-interval' expects a non-negative integer argument" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--async-actions-fetch-interval", "-10"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It accepts '--enable-remote-schema-permissions'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-remote-schema-permissions"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEnableRemoteSchemaPermissions result `Hspec.shouldSatisfy` \case
|
2022-07-29 03:45:51 +03:00
|
|
|
Opt.Success enableRemoteSchemaPermissions -> enableRemoteSchemaPermissions == Options.EnableRemoteSchemaPermissions
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enable-remote-schema-permissions' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-remote-schema-permissions", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--websocket-compression'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-compression"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoWebSocketCompression result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success webSocketCompression -> webSocketCompression == True
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--websocket-compression' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-compression", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--websocket-keepalive'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-keepalive", "8"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoWebSocketKeepAlive result `Hspec.shouldSatisfy` \case
|
2022-09-21 21:01:48 +03:00
|
|
|
Opt.Success webSocketKeepAlive -> webSocketKeepAlive == Just (UUT.KeepAliveDelay $$(refineTH 8))
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
Hspec.it "It fails '--websocket-keepalive' expects a non-negative integer" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-keepalive", "-10"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It fails '--websocket-keepalive' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-keepalive"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--websocket-keepalive' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-keepalive", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--infer-function-permissions'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--infer-function-permissions", "false"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoInferFunctionPermissions result `Hspec.shouldSatisfy` \case
|
2022-07-29 03:45:51 +03:00
|
|
|
Opt.Success inferFunctionPermissions -> inferFunctionPermissions == Just Options.Don'tInferFunctionPermissions
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--infer-function-permissions' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--infer-function-permissions"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--infer-function-permissions' expects a boolean argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--infer-function-permissions", "five"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--enable-maintenance-mode'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-maintenance-mode"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEnableMaintenanceMode result `Hspec.shouldSatisfy` \case
|
2022-07-29 03:45:51 +03:00
|
|
|
Opt.Success enableMaintenanceMode -> enableMaintenanceMode == Types.MaintenanceModeEnabled ()
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enable-maintenance-mode' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-maintenance-mode", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--schema-sync-poll-interval'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--schema-sync-poll-interval", "5432"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoSchemaPollInterval result `Hspec.shouldSatisfy` \case
|
2022-09-21 21:01:48 +03:00
|
|
|
Opt.Success schemaPollInterval -> schemaPollInterval == Just (UUT.Interval $$(refineTH 5432))
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--schema-sync-poll-interval' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--schema-sync-poll-interval"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--schema-sync-poll-interval' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--schema-sync-poll-interval", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
Hspec.it "It fails '--schema-sync-poll-interval' expects a non-negative integer argument" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--schema-sync-poll-interval", "-10"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It accepts '--experimental-features'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--experimental-features", "inherited_roles,optimize_permission_filters"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoExperimentalFeatures result `Hspec.shouldSatisfy` \case
|
2022-08-05 03:28:49 +03:00
|
|
|
Opt.Success schemaPollInterval -> schemaPollInterval == Just (Set.fromList [Types.EFInheritedRoles, Types.EFOptimizePermissionFilters])
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--experimental-features' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--experimental-features"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--experimental-features' expects a valid experimental feature options in the argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--experimental-features", "inherited_roles,pretend_feature"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--events-fetch-batch-size'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--events-fetch-batch-size", "40"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEventsFetchBatchSize result `Hspec.shouldSatisfy` \case
|
2022-09-21 21:01:48 +03:00
|
|
|
Opt.Success eventsFetchBatchSize -> eventsFetchBatchSize == Just $$(refineTH @NonNegative @Int 40)
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--events-fetch-batch-size' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--events-fetch-batch-size"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--events-fetch-batch-size' expects a non-negative integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--events-fetch-batch-size", "-40"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--graceful-shutdown-timeout'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--graceful-shutdown-timeout", "52"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoGracefulShutdownTimeout result `Hspec.shouldSatisfy` \case
|
2022-09-21 21:01:48 +03:00
|
|
|
Opt.Success gracefulShutdownTimeout -> gracefulShutdownTimeout == Just $$(refineTH @NonNegative @Seconds 52)
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--graceful-shutdown-timeout' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--graceful-shutdown-timeout"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--graceful-shutdown-timeout' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--graceful-shutdown-timeout", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
Hspec.it "It fails '--graceful-shutdown-timeout' expects a non-negative integer argument" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--graceful-shutdown-timeout", "-10"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It accepts '--websocket-connection-init-timeout'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-connection-init-timeout", "34"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoWebSocketConnectionInitTimeout result `Hspec.shouldSatisfy` \case
|
2022-09-21 21:01:48 +03:00
|
|
|
Opt.Success webSocketConnectionInitTimeout -> webSocketConnectionInitTimeout == Just (UUT.WSConnectionInitTimeout $$(refineTH 34))
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--websocket-connection-init-timeout' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-connection-init-timeout"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--websocket-connection-init-timeout' expects an integer argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-connection-init-timeout", "true"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-08-17 04:07:44 +03:00
|
|
|
Hspec.it "It fails '--websocket-connection-init-timeout' expects a non-negative integer argument" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput = ["--websocket-connection-init-timeout", "-10"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
2022-07-15 08:03:02 +03:00
|
|
|
Hspec.it "It accepts '--enable-metadata-query-logging'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-metadata-query-logging"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoEnableMetadataQueryLoggingEnv result `Hspec.shouldSatisfy` \case
|
2022-07-29 03:45:51 +03:00
|
|
|
Opt.Success enableMetadataQueryLogging -> enableMetadataQueryLogging == Logging.MetadataQueryLoggingEnabled
|
2022-07-15 08:03:02 +03:00
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--enable-metadata-query-logging' does not expect an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--enable-metadata-query-logging", "x"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It accepts '--default-naming-convention'" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--default-naming-convention", "graphql-default"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoDefaultNamingConvention result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success enableMetadataQueryLogging -> enableMetadataQueryLogging == Just NC.GraphqlCase
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It fails '--default-naming-convention' expects an argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--default-naming-convention"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
|
|
|
|
|
|
|
Hspec.it "It fails '--default-naming-convention' expects a valid naming convention argument" $ do
|
|
|
|
let -- Given
|
2022-07-15 11:54:27 +03:00
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
2022-07-15 08:03:02 +03:00
|
|
|
-- When
|
|
|
|
argInput = ["--default-naming-convention", "mysterious-default"]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
case result of
|
|
|
|
Opt.Success _result -> Hspec.expectationFailure "Should not parse successfully"
|
|
|
|
Opt.Failure _pf -> pure ()
|
|
|
|
Opt.CompletionInvoked cr -> Hspec.expectationFailure $ show cr
|
2022-10-20 15:45:31 +03:00
|
|
|
|
|
|
|
Hspec.it "It accepts '--metadata-defaults'" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput =
|
|
|
|
[ "--metadata-defaults",
|
|
|
|
"{\"backend_configs\": {\"dataconnector\": {\"sqlite\": {\"uri\": \"http://localhost:8100\"}}}}"
|
|
|
|
]
|
|
|
|
-- Then
|
|
|
|
result = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
|
|
|
|
fmap UUT.rsoMetadataDefaults result `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success (Just (MetadataDefaults md)) -> not (null (BackendMap.elems (_metaBackendConfigs md)))
|
|
|
|
Opt.Success Nothing -> False
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
|
|
|
|
Hspec.it "It prefers explicit metadata over '--metadata-defaults'" $ do
|
|
|
|
let -- Given
|
|
|
|
parserInfo = Opt.info (UUT.serveCommandParser @Logging.Hasura Opt.<**> Opt.helper) Opt.fullDesc
|
|
|
|
-- When
|
|
|
|
argInput =
|
|
|
|
[ "--metadata-defaults",
|
|
|
|
"{\"backend_configs\": {\"dataconnector\": {\"sqlite\": {\"uri\": \"http://x:80\"}, \"mongo\": {\"uri\": \"http://x:81\"}}}}"
|
|
|
|
]
|
|
|
|
mdInput =
|
|
|
|
"{\"version\": 3, \"sources\": [], \"backend_configs\": {\"dataconnector\": {\"sqlite\": {\"uri\": \"http://x:82\"}, \"db2\": {\"uri\": \"http://x:83\"}}}}"
|
|
|
|
mdExpected =
|
|
|
|
"{\"version\": 3, \"sources\": [], \"backend_configs\": {\"dataconnector\": { \"mongo\": {\"uri\": \"http://x:81\"}, \"sqlite\": {\"uri\": \"http://x:82\"}, \"db2\": {\"uri\": \"http://x:83\"}}}}"
|
|
|
|
|
|
|
|
-- Then
|
|
|
|
argResult = Opt.execParserPure Opt.defaultPrefs parserInfo argInput
|
|
|
|
mdResult = Aeson.eitherDecode @Metadata mdInput
|
|
|
|
mdExpectedResult = Aeson.eitherDecode @Metadata mdExpected
|
|
|
|
|
|
|
|
fmap UUT.rsoMetadataDefaults argResult `Hspec.shouldSatisfy` \case
|
|
|
|
Opt.Success Nothing -> False
|
|
|
|
Opt.Failure _pf -> False
|
|
|
|
Opt.CompletionInvoked _cr -> False
|
|
|
|
Opt.Success (Just (MetadataDefaults mdd)) ->
|
|
|
|
case (mdResult, mdExpectedResult) of
|
|
|
|
(Right md, Right mde) ->
|
|
|
|
let o = overrideMetadataDefaults md (MetadataDefaults mdd)
|
|
|
|
in o == mde
|
|
|
|
_ -> False
|