module Ribosome.Test.Embed (
  -- * Embedded Neovim testing
  -- $intro

  testPlugin,
  testEmbed,
  testPluginEmbed,
  runEmbedTest,
  runTest,
  testPluginConf,
  testPlugin_,
  testEmbedConf,
  testEmbed_,
  testEmbedLevel,
  testEmbedLevel_,
  testEmbedTrace,
  testEmbedDebug,
  testEmbedTrace_,
  testEmbedDebug_,
  runTestConf,
  runTestLogConf,
  EmbedStackWith,
  EmbedStack,
  EmbedHandlerStack,
  TestEffects,
) where

import Log (Severity (Debug, Trace))
import Polysemy.Test (TestError, UnitTest)

import Ribosome.Data.PluginConfig (PluginConfig (PluginConfig))
import Ribosome.Data.PluginName (PluginName)
import Ribosome.Data.SettingError (SettingError)
import Ribosome.Effect.Scratch (Scratch)
import Ribosome.Effect.Settings (Settings)
import Ribosome.Embed (HandlerEffects, embedPlugin, interpretPluginEmbed)
import Ribosome.Host.Data.BootError (BootError)
import Ribosome.Host.Data.HostConfig (setStderr)
import Ribosome.Host.Data.Report (Report)
import Ribosome.Host.Data.RpcError (RpcError)
import Ribosome.Host.Data.RpcHandler (RpcHandler)
import Ribosome.Host.Effect.Rpc (Rpc)
import Ribosome.Host.Error (resumeBootError)
import Ribosome.Host.Interpret (HigherOrder)
import Ribosome.Host.Interpreter.Handlers (withHandlers)
import Ribosome.Host.Interpreter.Host (HostDeps)
import qualified Ribosome.Host.Test.Data.TestConfig as Host
import qualified Ribosome.Host.Test.Run as Host
import Ribosome.Host.Test.Run (TestConfStack, TestStack, runUnitTest)
import Ribosome.Plugin.Builtin (BuiltinHandlersDeps)
import Ribosome.Test.Data.TestConfig (TestConfig (TestConfig))
import Ribosome.Test.Error (testError, testHandler)
import Ribosome.Test.Log (testLogLevel)

-- $intro
-- The function 'testPluginEmbed' starts an embedded Neovim subprocess and a Ribosome main loop, then executes the
-- supplied 'Sem'.
--
-- This can be interpreted into a "Hedgehog" 'Hedgehog.TestT' by using the functions 'runEmbedTest' and 'runTest'.
--
-- The functions 'testPluginConf' and 'testPlugin' run a full Ribosome plugin with RPC handlers and extra effects in
-- addition to the above.
-- This can be used to test calling RPC handlers from Neovim, which usually shouldn't be necessary but may be helpful
-- for some edge cases.
--
-- The functions 'testEmbedConf' and 'testEmbed' run tests with extra effects, but no handlers.
-- This is the most advisable way to test plugins, running handlers directly as Haskell functions instead of routing
-- them through Neovim, in particular for those that don't have any parameters.

-- |The extra effects that tests are expected to use, related to errors.
--
-- The plugin effects 'Scratch', 'Settings' and 'Rpc' are allowed without 'Resume', causing tests to terminate
-- immediately if one of these effects is used and throws an error.
--
-- Additionally, the two core errors, 'LogReport' and 'RpcError' are executed directly via 'Stop'.
type TestEffects =
  [
    Stop Report,
    Stop RpcError,
    Scratch,
    Settings,
    Rpc
  ]

-- |The full test stack below test effects and extra effects.
type EmbedHandlerStack =
  HandlerEffects ++ Reader PluginName : TestStack

-- |The full test stack with additional effects.
type EmbedStackWith r =
  TestEffects ++ r ++ EmbedHandlerStack

-- |The full test stack with no additional effects.
type EmbedStack =
  EmbedStackWith '[]

-- |Interpret the basic test effects without 'IO' related effects.
runTestLogConf ::
  Members [Error BootError, Resource, Race, Async, Embed IO] r =>
  TestConfig ->
  InterpretersFor (Reader PluginName : TestConfStack) r
runTestLogConf :: forall (r :: EffectRow).
Members '[Error BootError, Resource, Race, Async, Embed IO] r =>
TestConfig -> InterpretersFor (Reader PluginName : TestConfStack) r
runTestLogConf (TestConfig Bool
freezeTime (PluginConfig PluginName
name HostConfig
conf Parser ()
_)) =
  TestConfig -> InterpretersFor TestConfStack r
forall (r :: EffectRow).
Members '[Error BootError, Resource, Race, Async, Embed IO] r =>
TestConfig -> InterpretersFor TestConfStack r
Host.runTestLogConf (Bool -> HostConfig -> TestConfig
Host.TestConfig Bool
freezeTime HostConfig
conf) (Sem
   (Log
      : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
      : Reader HostConfig : Time Time Date : r)
   a
 -> Sem r a)
-> (Sem
      (Reader PluginName
         : Log : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
         : Reader HostConfig : Time Time Date : r)
      a
    -> Sem
         (Log
            : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
            : Reader HostConfig : Time Time Date : r)
         a)
-> Sem
     (Reader PluginName
        : Log : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
        : Reader HostConfig : Time Time Date : r)
     a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  PluginName
-> Sem
     (Reader PluginName
        : Log : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
        : Reader HostConfig : Time Time Date : r)
     a
-> Sem
     (Log
        : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
        : Reader HostConfig : Time Time Date : r)
     a
forall i (r :: EffectRow) a. i -> Sem (Reader i : r) a -> Sem r a
runReader PluginName
name

-- |Run the basic test effects as a "Hedgehog" test.
runTestConf ::
  HasCallStack =>
  TestConfig ->
  Sem (Reader PluginName : TestStack) () ->
  UnitTest
runTestConf :: HasCallStack =>
TestConfig -> Sem (Reader PluginName : TestStack) () -> UnitTest
runTestConf TestConfig
conf =
  HasCallStack => Sem TestIOStack () -> UnitTest
Sem TestIOStack () -> UnitTest
runUnitTest (Sem TestIOStack () -> UnitTest)
-> (Sem
      (Reader PluginName
         : Log : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
         : Reader HostConfig : Time Time Date : TestIOStack)
      ()
    -> Sem TestIOStack ())
-> Sem
     (Reader PluginName
        : Log : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
        : Reader HostConfig : Time Time Date : TestIOStack)
     ()
-> UnitTest
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  TestConfig
-> InterpretersFor (Reader PluginName : TestConfStack) TestIOStack
forall (r :: EffectRow).
Members '[Error BootError, Resource, Race, Async, Embed IO] r =>
TestConfig -> InterpretersFor (Reader PluginName : TestConfStack) r
runTestLogConf TestConfig
conf

-- |Run the plugin stack and the test stack, using the supplied config.
runEmbedTest ::
  HasCallStack =>
  TestConfig ->
  Sem EmbedHandlerStack () ->
  UnitTest
runEmbedTest :: HasCallStack => TestConfig -> Sem EmbedHandlerStack () -> UnitTest
runEmbedTest TestConfig
conf =
  HasCallStack =>
TestConfig -> Sem (Reader PluginName : TestStack) () -> UnitTest
TestConfig -> Sem (Reader PluginName : TestStack) () -> UnitTest
runTestConf TestConfig
conf (Sem
   (Reader PluginName
      : Log : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
      : Reader HostConfig : Time Time Date : TestIOStack)
   ()
 -> UnitTest)
-> (Sem
      (Resumable RpcError Scratch
         : Resumable SettingError Settings
         : Resumable Report VariableWatcher : Resumable Report Handlers
         : Log : DataLog LogReport : Resumable RpcError Rpc
         : Resumable RpcError (Responses RequestId Response)
         : Events (OutChan Event) Event
         : PScoped () (EventChan Event) (Consume Event) : Reports
         : Events (OutChan RpcMessage) RpcMessage
         : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
         : Process RpcMessage (Either Text RpcMessage) : UserError
         : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
         : Reader LogConfig : Reader HostConfig : Time Time Date
         : TestIOStack)
      ()
    -> Sem
         (Reader PluginName
            : Log : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
            : Reader HostConfig : Time Time Date : TestIOStack)
         ())
-> Sem
     (Resumable RpcError Scratch
        : Resumable SettingError Settings
        : Resumable Report VariableWatcher : Resumable Report Handlers
        : Log : DataLog LogReport : Resumable RpcError Rpc
        : Resumable RpcError (Responses RequestId Response)
        : Events (OutChan Event) Event
        : PScoped () (EventChan Event) (Consume Event) : Reports
        : Events (OutChan RpcMessage) RpcMessage
        : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
        : Process RpcMessage (Either Text RpcMessage) : UserError
        : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
        : Reader LogConfig : Reader HostConfig : Time Time Date
        : TestIOStack)
     ()
-> UnitTest
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  Sem
  (Resumable RpcError Scratch
     : Resumable SettingError Settings
     : Resumable Report VariableWatcher : Resumable Report Handlers
     : Log : DataLog LogReport : Resumable RpcError Rpc
     : Resumable RpcError (Responses RequestId Response)
     : Events (OutChan Event) Event
     : PScoped () (EventChan Event) (Consume Event) : Reports
     : Events (OutChan RpcMessage) RpcMessage
     : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
     : Process RpcMessage (Either Text RpcMessage) : UserError
     : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
     : Reader LogConfig : Reader HostConfig : Time Time Date
     : TestIOStack)
  ()
-> Sem
     (Reader PluginName
        : Log : Tagged "stderr" Log : Tagged "file" Log : Reader LogConfig
        : Reader HostConfig : Time Time Date : TestIOStack)
     ()
forall (r :: EffectRow).
(Members '[Log, Reader LogConfig, Reader PluginName] r,
 Members IOStack r) =>
InterpretersFor HandlerEffects r
interpretPluginEmbed

-- |Run the plugin stack and the test stack, using the default config.
runTest ::
  HasCallStack =>
  Sem EmbedHandlerStack () ->
  UnitTest
runTest :: HasCallStack => Sem EmbedHandlerStack () -> UnitTest
runTest =
  HasCallStack => TestConfig -> Sem EmbedHandlerStack () -> UnitTest
TestConfig -> Sem EmbedHandlerStack () -> UnitTest
runEmbedTest TestConfig
forall a. Default a => a
def

-- |Run the test plugin effects, 'TestEffects', and start an embedded Neovim subprocess.
testPluginEmbed ::
  Members (HostDeps er) r =>
  Members BuiltinHandlersDeps r =>
  Members [Settings !! SettingError, Error TestError] r =>
  InterpretersFor TestEffects r
testPluginEmbed :: forall er (r :: EffectRow).
(Members (HostDeps er) r, Members BuiltinHandlersDeps r,
 Members '[Resumable SettingError Settings, Error TestError] r) =>
InterpretersFor TestEffects r
testPluginEmbed =
  Sem r a -> Sem r a
forall er (r :: EffectRow) a.
(Members (HostDeps er) r, Members BuiltinHandlersDeps r) =>
Sem r a -> Sem r a
embedPlugin (Sem r a -> Sem r a)
-> (Sem
      (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
    -> Sem r a)
-> Sem
     (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  forall (eff :: (* -> *) -> * -> *) err (r :: EffectRow).
(Show err, Members '[eff !! err, Error BootError] r) =>
InterpreterFor eff r
resumeBootError @Rpc (Sem (Rpc : r) a -> Sem r a)
-> (Sem
      (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
    -> Sem (Rpc : r) a)
-> Sem
     (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  forall (eff :: (* -> *) -> * -> *) err (r :: EffectRow).
(Show err, Members '[eff !! err, Error BootError] r) =>
InterpreterFor eff r
resumeBootError @Settings (Sem (Settings : Rpc : r) a -> Sem (Rpc : r) a)
-> (Sem
      (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
    -> Sem (Settings : Rpc : r) a)
-> Sem
     (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
-> Sem (Rpc : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  forall (eff :: (* -> *) -> * -> *) err (r :: EffectRow).
(Show err, Members '[eff !! err, Error BootError] r) =>
InterpreterFor eff r
resumeBootError @Scratch (Sem (Scratch : Settings : Rpc : r) a
 -> Sem (Settings : Rpc : r) a)
-> (Sem
      (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
    -> Sem (Scratch : Settings : Rpc : r) a)
-> Sem
     (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
-> Sem (Settings : Rpc : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  Sem (Stop RpcError : Scratch : Settings : Rpc : r) a
-> Sem (Scratch : Settings : Rpc : r) a
forall err (r :: EffectRow) a.
(Reportable err, Member (Error TestError) r) =>
Sem (Stop err : r) a -> Sem r a
testError (Sem (Stop RpcError : Scratch : Settings : Rpc : r) a
 -> Sem (Scratch : Settings : Rpc : r) a)
-> (Sem
      (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
    -> Sem (Stop RpcError : Scratch : Settings : Rpc : r) a)
-> Sem
     (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
-> Sem (Scratch : Settings : Rpc : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  Sem (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
-> Sem (Stop RpcError : Scratch : Settings : Rpc : r) a
forall (r :: EffectRow) a.
Member (Error TestError) r =>
Handler r a -> Sem r a
testHandler (Sem (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
 -> Sem (Stop RpcError : Scratch : Settings : Rpc : r) a)
-> (Sem
      (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
    -> Sem
         (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a)
-> Sem
     (Stop Report : Stop RpcError : Scratch : Settings : Rpc : r) a
-> Sem (Stop RpcError : Scratch : Settings : Rpc : r) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  forall (index :: Nat) (inserted :: EffectRow) (head :: EffectRow)
       (oldTail :: EffectRow) (tail :: EffectRow) (old :: EffectRow)
       (full :: EffectRow) a.
(ListOfLength index head, WhenStuck index InsertAtUnprovidedIndex,
 old ~ Append head oldTail, tail ~ Append inserted oldTail,
 full ~ Append head tail,
 InsertAtIndex index head tail oldTail full inserted) =>
Sem old a -> Sem full a
insertAt @4

-- |Run a full plugin test, using extra effects and RPC handlers.
testPluginConf ::
   r .
  HasCallStack =>
  HigherOrder r EmbedHandlerStack =>
  TestConfig ->
  InterpretersFor r EmbedHandlerStack ->
  [RpcHandler (r ++ EmbedHandlerStack)] ->
  Sem (EmbedStackWith r) () ->
  UnitTest
testPluginConf :: forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
TestConfig
-> InterpretersFor r EmbedHandlerStack
-> [RpcHandler (r ++ EmbedHandlerStack)]
-> Sem (EmbedStackWith r) ()
-> UnitTest
testPluginConf TestConfig
conf InterpretersFor r EmbedHandlerStack
effs [RpcHandler (r ++ EmbedHandlerStack)]
handlers =
  HasCallStack => TestConfig -> Sem EmbedHandlerStack () -> UnitTest
TestConfig -> Sem EmbedHandlerStack () -> UnitTest
runEmbedTest TestConfig
conf (Sem
   (Resumable RpcError Scratch
      : Resumable SettingError Settings
      : Resumable Report VariableWatcher : Resumable Report Handlers
      : Log : DataLog LogReport : Resumable RpcError Rpc
      : Resumable RpcError (Responses RequestId Response)
      : Events (OutChan Event) Event
      : PScoped () (EventChan Event) (Consume Event) : Reports
      : Events (OutChan RpcMessage) RpcMessage
      : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
      : Process RpcMessage (Either Text RpcMessage) : UserError
      : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
      : Reader LogConfig : Reader HostConfig : Time Time Date
      : TestIOStack)
   ()
 -> UnitTest)
-> (Sem
      (Stop Report
         : Stop RpcError : Scratch : Settings : Rpc
         : Append
             r
             (Resumable RpcError Scratch
                : Resumable SettingError Settings
                : Resumable Report VariableWatcher : Resumable Report Handlers
                : Log : DataLog LogReport : Resumable RpcError Rpc
                : Resumable RpcError (Responses RequestId Response)
                : Events (OutChan Event) Event
                : PScoped () (EventChan Event) (Consume Event) : Reports
                : Events (OutChan RpcMessage) RpcMessage
                : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
                : Process RpcMessage (Either Text RpcMessage) : UserError
                : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
                : Reader LogConfig : Reader HostConfig : Time Time Date
                : TestIOStack))
      ()
    -> Sem
         (Resumable RpcError Scratch
            : Resumable SettingError Settings
            : Resumable Report VariableWatcher : Resumable Report Handlers
            : Log : DataLog LogReport : Resumable RpcError Rpc
            : Resumable RpcError (Responses RequestId Response)
            : Events (OutChan Event) Event
            : PScoped () (EventChan Event) (Consume Event) : Reports
            : Events (OutChan RpcMessage) RpcMessage
            : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
            : Process RpcMessage (Either Text RpcMessage) : UserError
            : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
            : Reader LogConfig : Reader HostConfig : Time Time Date
            : TestIOStack)
         ())
-> Sem
     (Stop Report
        : Stop RpcError : Scratch : Settings : Rpc
        : Append
            r
            (Resumable RpcError Scratch
               : Resumable SettingError Settings
               : Resumable Report VariableWatcher : Resumable Report Handlers
               : Log : DataLog LogReport : Resumable RpcError Rpc
               : Resumable RpcError (Responses RequestId Response)
               : Events (OutChan Event) Event
               : PScoped () (EventChan Event) (Consume Event) : Reports
               : Events (OutChan RpcMessage) RpcMessage
               : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
               : Process RpcMessage (Either Text RpcMessage) : UserError
               : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
               : Reader LogConfig : Reader HostConfig : Time Time Date
               : TestIOStack))
     ()
-> UnitTest
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  Sem
  (Append
     r
     (Resumable RpcError Scratch
        : Resumable SettingError Settings
        : Resumable Report VariableWatcher : Resumable Report Handlers
        : Log : DataLog LogReport : Resumable RpcError Rpc
        : Resumable RpcError (Responses RequestId Response)
        : Events (OutChan Event) Event
        : PScoped () (EventChan Event) (Consume Event) : Reports
        : Events (OutChan RpcMessage) RpcMessage
        : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
        : Process RpcMessage (Either Text RpcMessage) : UserError
        : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
        : Reader LogConfig : Reader HostConfig : Time Time Date
        : TestIOStack))
  ()
-> Sem
     (Resumable RpcError Scratch
        : Resumable SettingError Settings
        : Resumable Report VariableWatcher : Resumable Report Handlers
        : Log : DataLog LogReport : Resumable RpcError Rpc
        : Resumable RpcError (Responses RequestId Response)
        : Events (OutChan Event) Event
        : PScoped () (EventChan Event) (Consume Event) : Reports
        : Events (OutChan RpcMessage) RpcMessage
        : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
        : Process RpcMessage (Either Text RpcMessage) : UserError
        : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
        : Reader LogConfig : Reader HostConfig : Time Time Date
        : TestIOStack)
     ()
InterpretersFor r EmbedHandlerStack
effs (Sem
   (Append
      r
      (Resumable RpcError Scratch
         : Resumable SettingError Settings
         : Resumable Report VariableWatcher : Resumable Report Handlers
         : Log : DataLog LogReport : Resumable RpcError Rpc
         : Resumable RpcError (Responses RequestId Response)
         : Events (OutChan Event) Event
         : PScoped () (EventChan Event) (Consume Event) : Reports
         : Events (OutChan RpcMessage) RpcMessage
         : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
         : Process RpcMessage (Either Text RpcMessage) : UserError
         : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
         : Reader LogConfig : Reader HostConfig : Time Time Date
         : TestIOStack))
   ()
 -> Sem
      (Resumable RpcError Scratch
         : Resumable SettingError Settings
         : Resumable Report VariableWatcher : Resumable Report Handlers
         : Log : DataLog LogReport : Resumable RpcError Rpc
         : Resumable RpcError (Responses RequestId Response)
         : Events (OutChan Event) Event
         : PScoped () (EventChan Event) (Consume Event) : Reports
         : Events (OutChan RpcMessage) RpcMessage
         : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
         : Process RpcMessage (Either Text RpcMessage) : UserError
         : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
         : Reader LogConfig : Reader HostConfig : Time Time Date
         : TestIOStack)
      ())
-> (Sem
      (Stop Report
         : Stop RpcError : Scratch : Settings : Rpc
         : Append
             r
             (Resumable RpcError Scratch
                : Resumable SettingError Settings
                : Resumable Report VariableWatcher : Resumable Report Handlers
                : Log : DataLog LogReport : Resumable RpcError Rpc
                : Resumable RpcError (Responses RequestId Response)
                : Events (OutChan Event) Event
                : PScoped () (EventChan Event) (Consume Event) : Reports
                : Events (OutChan RpcMessage) RpcMessage
                : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
                : Process RpcMessage (Either Text RpcMessage) : UserError
                : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
                : Reader LogConfig : Reader HostConfig : Time Time Date
                : TestIOStack))
      ()
    -> Sem
         (Append
            r
            (Resumable RpcError Scratch
               : Resumable SettingError Settings
               : Resumable Report VariableWatcher : Resumable Report Handlers
               : Log : DataLog LogReport : Resumable RpcError Rpc
               : Resumable RpcError (Responses RequestId Response)
               : Events (OutChan Event) Event
               : PScoped () (EventChan Event) (Consume Event) : Reports
               : Events (OutChan RpcMessage) RpcMessage
               : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
               : Process RpcMessage (Either Text RpcMessage) : UserError
               : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
               : Reader LogConfig : Reader HostConfig : Time Time Date
               : TestIOStack))
         ())
-> Sem
     (Stop Report
        : Stop RpcError : Scratch : Settings : Rpc
        : Append
            r
            (Resumable RpcError Scratch
               : Resumable SettingError Settings
               : Resumable Report VariableWatcher : Resumable Report Handlers
               : Log : DataLog LogReport : Resumable RpcError Rpc
               : Resumable RpcError (Responses RequestId Response)
               : Events (OutChan Event) Event
               : PScoped () (EventChan Event) (Consume Event) : Reports
               : Events (OutChan RpcMessage) RpcMessage
               : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
               : Process RpcMessage (Either Text RpcMessage) : UserError
               : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
               : Reader LogConfig : Reader HostConfig : Time Time Date
               : TestIOStack))
     ()
-> Sem
     (Resumable RpcError Scratch
        : Resumable SettingError Settings
        : Resumable Report VariableWatcher : Resumable Report Handlers
        : Log : DataLog LogReport : Resumable RpcError Rpc
        : Resumable RpcError (Responses RequestId Response)
        : Events (OutChan Event) Event
        : PScoped () (EventChan Event) (Consume Event) : Reports
        : Events (OutChan RpcMessage) RpcMessage
        : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
        : Process RpcMessage (Either Text RpcMessage) : UserError
        : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
        : Reader LogConfig : Reader HostConfig : Time Time Date
        : TestIOStack)
     ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  [RpcHandler
   (Append
      r
      (Resumable RpcError Scratch
         : Resumable SettingError Settings
         : Resumable Report VariableWatcher : Resumable Report Handlers
         : Log : DataLog LogReport : Resumable RpcError Rpc
         : Resumable RpcError (Responses RequestId Response)
         : Events (OutChan Event) Event
         : PScoped () (EventChan Event) (Consume Event) : Reports
         : Events (OutChan RpcMessage) RpcMessage
         : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
         : Process RpcMessage (Either Text RpcMessage) : UserError
         : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
         : Reader LogConfig : Reader HostConfig : Time Time Date
         : TestIOStack))]
-> Sem
     (Append
        r
        (Resumable RpcError Scratch
           : Resumable SettingError Settings
           : Resumable Report VariableWatcher : Resumable Report Handlers
           : Log : DataLog LogReport : Resumable RpcError Rpc
           : Resumable RpcError (Responses RequestId Response)
           : Events (OutChan Event) Event
           : PScoped () (EventChan Event) (Consume Event) : Reports
           : Events (OutChan RpcMessage) RpcMessage
           : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
           : Process RpcMessage (Either Text RpcMessage) : UserError
           : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
           : Reader LogConfig : Reader HostConfig : Time Time Date
           : TestIOStack))
     ()
-> Sem
     (Append
        r
        (Resumable RpcError Scratch
           : Resumable SettingError Settings
           : Resumable Report VariableWatcher : Resumable Report Handlers
           : Log : DataLog LogReport : Resumable RpcError Rpc
           : Resumable RpcError (Responses RequestId Response)
           : Events (OutChan Event) Event
           : PScoped () (EventChan Event) (Consume Event) : Reports
           : Events (OutChan RpcMessage) RpcMessage
           : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
           : Process RpcMessage (Either Text RpcMessage) : UserError
           : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
           : Reader LogConfig : Reader HostConfig : Time Time Date
           : TestIOStack))
     ()
forall (r :: EffectRow) a.
Members
  '[Resumable Report Handlers, Resumable RpcError Rpc, Log,
    Error BootError]
  r =>
[RpcHandler r] -> Sem r a -> Sem r a
withHandlers [RpcHandler
   (Append
      r
      (Resumable RpcError Scratch
         : Resumable SettingError Settings
         : Resumable Report VariableWatcher : Resumable Report Handlers
         : Log : DataLog LogReport : Resumable RpcError Rpc
         : Resumable RpcError (Responses RequestId Response)
         : Events (OutChan Event) Event
         : PScoped () (EventChan Event) (Consume Event) : Reports
         : Events (OutChan RpcMessage) RpcMessage
         : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
         : Process RpcMessage (Either Text RpcMessage) : UserError
         : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
         : Reader LogConfig : Reader HostConfig : Time Time Date
         : TestIOStack))]
[RpcHandler (r ++ EmbedHandlerStack)]
handlers (Sem
   (Append
      r
      (Resumable RpcError Scratch
         : Resumable SettingError Settings
         : Resumable Report VariableWatcher : Resumable Report Handlers
         : Log : DataLog LogReport : Resumable RpcError Rpc
         : Resumable RpcError (Responses RequestId Response)
         : Events (OutChan Event) Event
         : PScoped () (EventChan Event) (Consume Event) : Reports
         : Events (OutChan RpcMessage) RpcMessage
         : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
         : Process RpcMessage (Either Text RpcMessage) : UserError
         : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
         : Reader LogConfig : Reader HostConfig : Time Time Date
         : TestIOStack))
   ()
 -> Sem
      (Append
         r
         (Resumable RpcError Scratch
            : Resumable SettingError Settings
            : Resumable Report VariableWatcher : Resumable Report Handlers
            : Log : DataLog LogReport : Resumable RpcError Rpc
            : Resumable RpcError (Responses RequestId Response)
            : Events (OutChan Event) Event
            : PScoped () (EventChan Event) (Consume Event) : Reports
            : Events (OutChan RpcMessage) RpcMessage
            : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
            : Process RpcMessage (Either Text RpcMessage) : UserError
            : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
            : Reader LogConfig : Reader HostConfig : Time Time Date
            : TestIOStack))
      ())
-> (Sem
      (Stop Report
         : Stop RpcError : Scratch : Settings : Rpc
         : Append
             r
             (Resumable RpcError Scratch
                : Resumable SettingError Settings
                : Resumable Report VariableWatcher : Resumable Report Handlers
                : Log : DataLog LogReport : Resumable RpcError Rpc
                : Resumable RpcError (Responses RequestId Response)
                : Events (OutChan Event) Event
                : PScoped () (EventChan Event) (Consume Event) : Reports
                : Events (OutChan RpcMessage) RpcMessage
                : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
                : Process RpcMessage (Either Text RpcMessage) : UserError
                : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
                : Reader LogConfig : Reader HostConfig : Time Time Date
                : TestIOStack))
      ()
    -> Sem
         (Append
            r
            (Resumable RpcError Scratch
               : Resumable SettingError Settings
               : Resumable Report VariableWatcher : Resumable Report Handlers
               : Log : DataLog LogReport : Resumable RpcError Rpc
               : Resumable RpcError (Responses RequestId Response)
               : Events (OutChan Event) Event
               : PScoped () (EventChan Event) (Consume Event) : Reports
               : Events (OutChan RpcMessage) RpcMessage
               : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
               : Process RpcMessage (Either Text RpcMessage) : UserError
               : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
               : Reader LogConfig : Reader HostConfig : Time Time Date
               : TestIOStack))
         ())
-> Sem
     (Stop Report
        : Stop RpcError : Scratch : Settings : Rpc
        : Append
            r
            (Resumable RpcError Scratch
               : Resumable SettingError Settings
               : Resumable Report VariableWatcher : Resumable Report Handlers
               : Log : DataLog LogReport : Resumable RpcError Rpc
               : Resumable RpcError (Responses RequestId Response)
               : Events (OutChan Event) Event
               : PScoped () (EventChan Event) (Consume Event) : Reports
               : Events (OutChan RpcMessage) RpcMessage
               : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
               : Process RpcMessage (Either Text RpcMessage) : UserError
               : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
               : Reader LogConfig : Reader HostConfig : Time Time Date
               : TestIOStack))
     ()
-> Sem
     (Append
        r
        (Resumable RpcError Scratch
           : Resumable SettingError Settings
           : Resumable Report VariableWatcher : Resumable Report Handlers
           : Log : DataLog LogReport : Resumable RpcError Rpc
           : Resumable RpcError (Responses RequestId Response)
           : Events (OutChan Event) Event
           : PScoped () (EventChan Event) (Consume Event) : Reports
           : Events (OutChan RpcMessage) RpcMessage
           : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
           : Process RpcMessage (Either Text RpcMessage) : UserError
           : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
           : Reader LogConfig : Reader HostConfig : Time Time Date
           : TestIOStack))
     ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
  Sem
  (Stop Report
     : Stop RpcError : Scratch : Settings : Rpc
     : Append
         r
         (Resumable RpcError Scratch
            : Resumable SettingError Settings
            : Resumable Report VariableWatcher : Resumable Report Handlers
            : Log : DataLog LogReport : Resumable RpcError Rpc
            : Resumable RpcError (Responses RequestId Response)
            : Events (OutChan Event) Event
            : PScoped () (EventChan Event) (Consume Event) : Reports
            : Events (OutChan RpcMessage) RpcMessage
            : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
            : Process RpcMessage (Either Text RpcMessage) : UserError
            : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
            : Reader LogConfig : Reader HostConfig : Time Time Date
            : TestIOStack))
  ()
-> Sem
     (Append
        r
        (Resumable RpcError Scratch
           : Resumable SettingError Settings
           : Resumable Report VariableWatcher : Resumable Report Handlers
           : Log : DataLog LogReport : Resumable RpcError Rpc
           : Resumable RpcError (Responses RequestId Response)
           : Events (OutChan Event) Event
           : PScoped () (EventChan Event) (Consume Event) : Reports
           : Events (OutChan RpcMessage) RpcMessage
           : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
           : Process RpcMessage (Either Text RpcMessage) : UserError
           : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
           : Reader LogConfig : Reader HostConfig : Time Time Date
           : TestIOStack))
     ()
forall er (r :: EffectRow).
(Members (HostDeps er) r, Members BuiltinHandlersDeps r,
 Members '[Resumable SettingError Settings, Error TestError] r) =>
InterpretersFor TestEffects r
testPluginEmbed

-- |Run a full plugin test, using extra effects and RPC handlers.
testPlugin ::
   r .
  HasCallStack =>
  HigherOrder r EmbedHandlerStack =>
  InterpretersFor r EmbedHandlerStack ->
  [RpcHandler (r ++ EmbedHandlerStack)] ->
  Sem (EmbedStackWith r) () ->
  UnitTest
testPlugin :: forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
InterpretersFor r EmbedHandlerStack
-> [RpcHandler (r ++ EmbedHandlerStack)]
-> Sem (EmbedStackWith r) ()
-> UnitTest
testPlugin =
  forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
TestConfig
-> InterpretersFor r EmbedHandlerStack
-> [RpcHandler (r ++ EmbedHandlerStack)]
-> Sem (EmbedStackWith r) ()
-> UnitTest
testPluginConf @r TestConfig
forall a. Default a => a
def

-- |Run a plugin test with RPC handlers.
testPlugin_ ::
  HasCallStack =>
  [RpcHandler EmbedHandlerStack] ->
  Sem EmbedStack () ->
  UnitTest
testPlugin_ :: HasCallStack =>
[RpcHandler EmbedHandlerStack] -> Sem EmbedStack () -> UnitTest
testPlugin_ =
  forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
InterpretersFor r EmbedHandlerStack
-> [RpcHandler (r ++ EmbedHandlerStack)]
-> Sem (EmbedStackWith r) ()
-> UnitTest
testPlugin @'[] forall a. a -> a
InterpretersFor '[] EmbedHandlerStack
id

-- |Run a plugin test with extra effects but no RPC handlers.
testEmbedConf ::
   r .
  HasCallStack =>
  HigherOrder r EmbedHandlerStack =>
  TestConfig ->
  InterpretersFor r EmbedHandlerStack ->
  Sem (EmbedStackWith r) () ->
  UnitTest
testEmbedConf :: forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
TestConfig
-> InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) ()
-> UnitTest
testEmbedConf TestConfig
conf InterpretersFor r EmbedHandlerStack
effs =
  forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
TestConfig
-> InterpretersFor r EmbedHandlerStack
-> [RpcHandler (r ++ EmbedHandlerStack)]
-> Sem (EmbedStackWith r) ()
-> UnitTest
testPluginConf @r TestConfig
conf InterpretersFor r EmbedHandlerStack
effs [RpcHandler (r ++ EmbedHandlerStack)]
forall a. Monoid a => a
mempty

-- |Run a plugin test with extra effects but no RPC handlers.
testEmbed ::
   r .
  HasCallStack =>
  HigherOrder r EmbedHandlerStack =>
  InterpretersFor r EmbedHandlerStack ->
  Sem (EmbedStackWith r) () ->
  UnitTest
testEmbed :: forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) () -> UnitTest
testEmbed =
  forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
TestConfig
-> InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) ()
-> UnitTest
testEmbedConf @r TestConfig
forall a. Default a => a
def

-- |Run a plugin test with extra effects but no RPC handlers.
--
-- Takes a log level, for which the default is to only print critical errors.
testEmbedLevel ::
   r .
  HasCallStack =>
  HigherOrder r EmbedHandlerStack =>
  Severity ->
  InterpretersFor r EmbedHandlerStack ->
  Sem (EmbedStackWith r) () ->
  UnitTest
testEmbedLevel :: forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
Severity
-> InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) ()
-> UnitTest
testEmbedLevel Severity
level =
  forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
TestConfig
-> InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) ()
-> UnitTest
testEmbedConf @r (TestConfig
forall a. Default a => a
def TestConfig -> (TestConfig -> TestConfig) -> TestConfig
forall a b. a -> (a -> b) -> b
& IsLabel
  "plugin"
  ((PluginConfig () -> Identity (PluginConfig ()))
   -> TestConfig -> Identity TestConfig)
(PluginConfig () -> Identity (PluginConfig ()))
-> TestConfig -> Identity TestConfig
#plugin ((PluginConfig () -> Identity (PluginConfig ()))
 -> TestConfig -> Identity TestConfig)
-> ((HostConfig -> Identity HostConfig)
    -> PluginConfig () -> Identity (PluginConfig ()))
-> (HostConfig -> Identity HostConfig)
-> TestConfig
-> Identity TestConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IsLabel
  "host"
  ((HostConfig -> Identity HostConfig)
   -> PluginConfig () -> Identity (PluginConfig ()))
(HostConfig -> Identity HostConfig)
-> PluginConfig () -> Identity (PluginConfig ())
#host ((HostConfig -> Identity HostConfig)
 -> TestConfig -> Identity TestConfig)
-> (HostConfig -> HostConfig) -> TestConfig -> TestConfig
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Severity -> HostConfig -> HostConfig
setStderr Severity
level)

-- |Run a plugin test with extra effects but no RPC handlers at the 'Debug' log level.
testEmbedDebug ::
   r .
  HasCallStack =>
  HigherOrder r EmbedHandlerStack =>
  InterpretersFor r EmbedHandlerStack ->
  Sem (EmbedStackWith r) () ->
  UnitTest
testEmbedDebug :: forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) () -> UnitTest
testEmbedDebug InterpretersFor r EmbedHandlerStack
effs =
  Severity
-> (TestConfig
    -> Sem
         (Stop Report
            : Stop RpcError : Scratch : Settings : Rpc
            : Append
                r
                (Resumable RpcError Scratch
                   : Resumable SettingError Settings
                   : Resumable Report VariableWatcher : Resumable Report Handlers
                   : Log : DataLog LogReport : Resumable RpcError Rpc
                   : Resumable RpcError (Responses RequestId Response)
                   : Events (OutChan Event) Event
                   : PScoped () (EventChan Event) (Consume Event) : Reports
                   : Events (OutChan RpcMessage) RpcMessage
                   : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
                   : Process RpcMessage (Either Text RpcMessage) : UserError
                   : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
                   : Reader LogConfig : Reader HostConfig : Time Time Date
                   : TestIOStack))
         ()
    -> UnitTest)
-> Sem
     (Stop Report
        : Stop RpcError : Scratch : Settings : Rpc
        : Append
            r
            (Resumable RpcError Scratch
               : Resumable SettingError Settings
               : Resumable Report VariableWatcher : Resumable Report Handlers
               : Log : DataLog LogReport : Resumable RpcError Rpc
               : Resumable RpcError (Responses RequestId Response)
               : Events (OutChan Event) Event
               : PScoped () (EventChan Event) (Consume Event) : Reports
               : Events (OutChan RpcMessage) RpcMessage
               : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
               : Process RpcMessage (Either Text RpcMessage) : UserError
               : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
               : Reader LogConfig : Reader HostConfig : Time Time Date
               : TestIOStack))
     ()
-> UnitTest
forall a. HasCallStack => Severity -> (TestConfig -> a) -> a
testLogLevel Severity
Debug \ TestConfig
conf -> forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
TestConfig
-> InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) ()
-> UnitTest
testEmbedConf @r TestConfig
conf InterpretersFor r EmbedHandlerStack
effs

-- |Run a plugin test with extra effects but no RPC handlers at the 'Trace' log level for debugging RPC traffic.
testEmbedTrace ::
   r .
  HasCallStack =>
  HigherOrder r EmbedHandlerStack =>
  InterpretersFor r EmbedHandlerStack ->
  Sem (EmbedStackWith r) () ->
  UnitTest
testEmbedTrace :: forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) () -> UnitTest
testEmbedTrace InterpretersFor r EmbedHandlerStack
effs =
  Severity
-> (TestConfig
    -> Sem
         (Stop Report
            : Stop RpcError : Scratch : Settings : Rpc
            : Append
                r
                (Resumable RpcError Scratch
                   : Resumable SettingError Settings
                   : Resumable Report VariableWatcher : Resumable Report Handlers
                   : Log : DataLog LogReport : Resumable RpcError Rpc
                   : Resumable RpcError (Responses RequestId Response)
                   : Events (OutChan Event) Event
                   : PScoped () (EventChan Event) (Consume Event) : Reports
                   : Events (OutChan RpcMessage) RpcMessage
                   : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
                   : Process RpcMessage (Either Text RpcMessage) : UserError
                   : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
                   : Reader LogConfig : Reader HostConfig : Time Time Date
                   : TestIOStack))
         ()
    -> UnitTest)
-> Sem
     (Stop Report
        : Stop RpcError : Scratch : Settings : Rpc
        : Append
            r
            (Resumable RpcError Scratch
               : Resumable SettingError Settings
               : Resumable Report VariableWatcher : Resumable Report Handlers
               : Log : DataLog LogReport : Resumable RpcError Rpc
               : Resumable RpcError (Responses RequestId Response)
               : Events (OutChan Event) Event
               : PScoped () (EventChan Event) (Consume Event) : Reports
               : Events (OutChan RpcMessage) RpcMessage
               : PScoped () (EventChan RpcMessage) (Consume RpcMessage)
               : Process RpcMessage (Either Text RpcMessage) : UserError
               : Reader PluginName : Log : Tagged "stderr" Log : Tagged "file" Log
               : Reader LogConfig : Reader HostConfig : Time Time Date
               : TestIOStack))
     ()
-> UnitTest
forall a. HasCallStack => Severity -> (TestConfig -> a) -> a
testLogLevel Severity
Trace \ TestConfig
conf -> forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
TestConfig
-> InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) ()
-> UnitTest
testEmbedConf @r TestConfig
conf InterpretersFor r EmbedHandlerStack
effs

-- |Run a plugin test without extra effects and RPC handlers.
testEmbed_ ::
  HasCallStack =>
  Sem EmbedStack () ->
  UnitTest
testEmbed_ :: HasCallStack => Sem EmbedStack () -> UnitTest
testEmbed_ =
  HasCallStack =>
[RpcHandler EmbedHandlerStack] -> Sem EmbedStack () -> UnitTest
[RpcHandler EmbedHandlerStack] -> Sem EmbedStack () -> UnitTest
testPlugin_ [RpcHandler EmbedHandlerStack]
forall a. Monoid a => a
mempty

-- |Run a plugin test without extra effects and RPC handlers.
--
-- Takes a log level, for which the default is to only print critical errors.
testEmbedLevel_ ::
  HasCallStack =>
  Severity ->
  Sem EmbedStack () ->
  UnitTest
testEmbedLevel_ :: HasCallStack => Severity -> Sem EmbedStack () -> UnitTest
testEmbedLevel_ Severity
level =
  forall (r :: EffectRow).
(HasCallStack, HigherOrder r EmbedHandlerStack) =>
TestConfig
-> InterpretersFor r EmbedHandlerStack
-> Sem (EmbedStackWith r) ()
-> UnitTest
testEmbedConf @'[] (TestConfig
forall a. Default a => a
def TestConfig -> (TestConfig -> TestConfig) -> TestConfig
forall a b. a -> (a -> b) -> b
& IsLabel
  "plugin"
  ((PluginConfig () -> Identity (PluginConfig ()))
   -> TestConfig -> Identity TestConfig)
(PluginConfig () -> Identity (PluginConfig ()))
-> TestConfig -> Identity TestConfig
#plugin ((PluginConfig () -> Identity (PluginConfig ()))
 -> TestConfig -> Identity TestConfig)
-> ((HostConfig -> Identity HostConfig)
    -> PluginConfig () -> Identity (PluginConfig ()))
-> (HostConfig -> Identity HostConfig)
-> TestConfig
-> Identity TestConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IsLabel
  "host"
  ((HostConfig -> Identity HostConfig)
   -> PluginConfig () -> Identity (PluginConfig ()))
(HostConfig -> Identity HostConfig)
-> PluginConfig () -> Identity (PluginConfig ())
#host ((HostConfig -> Identity HostConfig)
 -> TestConfig -> Identity TestConfig)
-> (HostConfig -> HostConfig) -> TestConfig -> TestConfig
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ Severity -> HostConfig -> HostConfig
setStderr Severity
level) forall a. a -> a
InterpretersFor '[] EmbedHandlerStack
id

-- |Run a plugin test without extra effects and RPC handlers at the 'Debug' log level.
testEmbedDebug_ ::
  HasCallStack =>
  Sem EmbedStack () ->
  UnitTest
testEmbedDebug_ :: HasCallStack => Sem EmbedStack () -> UnitTest
testEmbedDebug_ =
  HasCallStack => Severity -> Sem EmbedStack () -> UnitTest
Severity -> Sem EmbedStack () -> UnitTest
testEmbedLevel_ Severity
Debug

-- |Run a plugin test without extra effects and RPC handlers at the 'Trace' log level for debugging RPC traffic.
testEmbedTrace_ ::
  HasCallStack =>
  Sem EmbedStack () ->
  UnitTest
testEmbedTrace_ :: HasCallStack => Sem EmbedStack () -> UnitTest
testEmbedTrace_ =
  HasCallStack => Severity -> Sem EmbedStack () -> UnitTest
Severity -> Sem EmbedStack () -> UnitTest
testEmbedLevel_ Severity
Trace