diff --git a/lib/core/test/integration/Test/Integration/Scenario/CLI/Server.hs b/lib/core/test/integration/Test/Integration/Scenario/CLI/Server.hs index 226466c7255..f9ab18374d9 100644 --- a/lib/core/test/integration/Test/Integration/Scenario/CLI/Server.hs +++ b/lib/core/test/integration/Test/Integration/Scenario/CLI/Server.hs @@ -6,41 +6,39 @@ import Prelude import Cardano.Launcher ( Command (..), StdStream (..) ) +import System.IO.Temp + ( withSystemTempDirectory ) import System.Directory - ( doesFileExist, removePathForcibly ) + ( doesFileExist ) import Test.Hspec - ( SpecWith, after_, describe, it ) + ( SpecWith, describe, it ) import Test.Hspec.Expectations.Lifted ( shouldReturn ) import Test.Integration.Framework.DSL ( Context (..), expectCmdStarts ) spec :: SpecWith (Context t) -spec = after_ tearDown $ do +spec = do describe "SERVER - cardano-wallet serve" $ do - it "SERVER - Can start cardano-wallet serve without --database" $ \_ -> do + it "SERVER - Can just start cardano-wallet serve" $ \_ -> do let cardanoWalletServer = Command "stack" [ "exec", "--", "cardano-wallet", "serve" ] (return ()) Inherit expectCmdStarts cardanoWalletServer - doesFileExist dbFile `shouldReturn` False - doesFileExist (dbFile ++ "-shm") `shouldReturn` False - doesFileExist (dbFile ++ "-wal") `shouldReturn` False - it "SERVER - Can start cardano-wallet serve with --database" $ \_ -> do - let cardanoWalletServer = Command "stack" - [ "exec", "--", "cardano-wallet", "serve" - , "--database", dbFile - ] (return ()) - Inherit - expectCmdStarts cardanoWalletServer - doesFileExist dbFile `shouldReturn` True - doesFileExist (dbFile ++ "-shm") `shouldReturn` True - doesFileExist (dbFile ++ "-wal") `shouldReturn` True - where - dbFile = "./test/data/test-DB-File" - tearDown = do - removePathForcibly dbFile - removePathForcibly (dbFile ++ "-shm") - removePathForcibly (dbFile ++ "-wal") + it "SERVER - Can start cardano-wallet serve --database" $ \_ -> do + withTempDir $ \d -> do + let dbFile = d ++ "/db-file" + let cardanoWalletServer = Command "stack" + [ "exec", "--", "cardano-wallet", "serve" + , "--database", dbFile + ] (return ()) + Inherit + expectCmdStarts cardanoWalletServer + doesFileExist dbFile `shouldReturn` True + doesFileExist (dbFile ++ "-shm") `shouldReturn` True + doesFileExist (dbFile ++ "-wal") `shouldReturn` True + +withTempDir :: (FilePath -> IO a) -> IO a +withTempDir = withSystemTempDirectory "integration-state"