Fire up a separate LDAP server instance for each example
This commit is contained in:
parent
3543e6a0b6
commit
cfaabed84e
@ -1,4 +1,4 @@
|
||||
guard :haskell, all_on_start: true, all_on_pass: true, cmd: "cabal exec -- ghci -isrc -itest -DTEST test/Main.hs -ignore-dot-ghci -optP-include -optPdist/build/autogen/cabal_macros.h" do
|
||||
guard :haskell, all_on_start: true, all_on_pass: true, cmd: "cabal exec -- ghci -isrc -itest -DTEST test/Spec.hs -ignore-dot-ghci -optP-include -optPdist/build/autogen/cabal_macros.h" do
|
||||
watch(%r{test/.+Spec\.l?hs$})
|
||||
watch(%r{src/.+\.l?hs$})
|
||||
watch(%r{.+\.cabal$})
|
||||
|
||||
@ -50,7 +50,7 @@ test-suite spec
|
||||
hs-source-dirs:
|
||||
test
|
||||
main-is:
|
||||
Main.hs
|
||||
Spec.hs
|
||||
other-modules:
|
||||
Ldap.ClientSpec
|
||||
build-depends:
|
||||
|
||||
24
test/Main.hs
24
test/Main.hs
@ -1,24 +0,0 @@
|
||||
module Main (main) where
|
||||
|
||||
import Control.Concurrent (threadDelay)
|
||||
import Control.Exception (bracket)
|
||||
import System.IO (hGetLine)
|
||||
import System.Process (runInteractiveProcess, terminateProcess, waitForProcess)
|
||||
import Test.Hspec
|
||||
|
||||
import qualified Spec
|
||||
import SpecHelper (port)
|
||||
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
bracket (do (_, out, _, h) <- runInteractiveProcess "./test/ldap.js" [] Nothing
|
||||
(Just [ ("PORT", show port)
|
||||
, ("SSL_CERT", "./ssl/cert.pem")
|
||||
, ("SSL_KEY", "./ssl/key.pem")
|
||||
])
|
||||
hGetLine out
|
||||
return h)
|
||||
(\h -> do terminateProcess h
|
||||
waitForProcess h)
|
||||
(\_ -> hspec Spec.spec)
|
||||
@ -1 +1 @@
|
||||
{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --module-name=Spec #-}
|
||||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
|
||||
|
||||
@ -21,11 +21,25 @@ module SpecHelper
|
||||
, oddish
|
||||
) where
|
||||
|
||||
import Control.Exception (bracket)
|
||||
import System.IO (hGetLine)
|
||||
import System.Process (runInteractiveProcess, terminateProcess, waitForProcess)
|
||||
|
||||
import Ldap.Client as Ldap
|
||||
|
||||
|
||||
locally :: (Ldap -> IO a) -> IO (Either LdapError a)
|
||||
locally = Ldap.with localhost port
|
||||
locally f =
|
||||
bracket (do (_, out, _, h) <- runInteractiveProcess "./test/ldap.js" [] Nothing
|
||||
(Just [ ("PORT", show port)
|
||||
, ("SSL_CERT", "./ssl/cert.pem")
|
||||
, ("SSL_KEY", "./ssl/key.pem")
|
||||
])
|
||||
hGetLine out
|
||||
return h)
|
||||
(\h -> do terminateProcess h
|
||||
waitForProcess h)
|
||||
(\_ -> Ldap.with localhost port f)
|
||||
|
||||
localhost :: Host
|
||||
localhost = Insecure "localhost"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user