From 754918b7a8f05e8284b27de70597c44ba61b9f1b Mon Sep 17 00:00:00 2001 From: Felix Mino Date: Thu, 4 Mar 2021 14:28:43 -0500 Subject: [PATCH] Testing releasePath --- CHANGELOG.md | 4 ++++ hapistrano.cabal | 2 +- spec/System/HapistranoSpec.hs | 37 +++++++++++++++++++++++++---------- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d6fefd..2c56c31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.4.2.0 +### Added +* Add support for working directory + ## 0.4.1.3 ### Changed * Allow formatting-7.0 diff --git a/hapistrano.cabal b/hapistrano.cabal index 5315d5c..e077faa 100644 --- a/hapistrano.cabal +++ b/hapistrano.cabal @@ -1,5 +1,5 @@ name: hapistrano -version: 0.4.1.3 +version: 0.4.2.0 synopsis: A deployment library for Haskell applications description: . diff --git a/spec/System/HapistranoSpec.hs b/spec/System/HapistranoSpec.hs index 9cf2699..4897c97 100644 --- a/spec/System/HapistranoSpec.hs +++ b/spec/System/HapistranoSpec.hs @@ -12,6 +12,7 @@ import Data.List (isPrefixOf) import Data.Maybe (mapMaybe) import Numeric.Natural import Path +import Path.Internal (Path(..)) import Path.IO import System.Directory (listDirectory) import qualified System.Hapistrano as Hap @@ -21,6 +22,7 @@ import System.Hapistrano.Types import System.IO import System.IO.Silently (capture_) import System.Info (os) +import qualified System.FilePath as SF import Test.Hspec hiding (shouldBe, shouldReturn) import qualified Test.Hspec as Hspec import Test.Hspec.QuickCheck @@ -29,18 +31,14 @@ import Test.QuickCheck testBranchName :: String testBranchName = "another_branch" +workingDir :: Path Rel Dir +workingDir = Path "working_dir" + +releaseDir :: FilePath +releaseDir = toFilePath (Path "releases") + spec :: Spec spec = do - fdescribe "releasePath" $ do - context "when the configWorkingDir is Nothing" $ - it "..." $ do - runHap $ Hap.releasePath undefined undefined Nothing - pending - - context "when the configWorkingDir is Just" $ - it "..." $ - pending - describe "execWithInheritStdout" $ context "given a command that prints to stdout" $ it "redirects commands' output to stdout first" $ @@ -104,6 +102,25 @@ spec = do it "returns the default value" $ fromMaybeKeepReleases Nothing Nothing `Hspec.shouldBe` 5 around withSandbox $ do + fdescribe "releasePath" $ do + context "when the configWorkingDir is Nothing" $ + it "should return the release path" $ \(deployPath, repoPath) -> do + (rpath, release) <- runHap $ do + release <- Hap.pushRelease $ mkTask deployPath repoPath + (,) <$> Hap.releasePath deployPath release Nothing + <*> pure release + + toFilePath rpath `shouldBe` toFilePath deployPath SF. releaseDir SF. (renderRelease release <> [SF.pathSeparator]) + + context "when the configWorkingDir is Just" $ + it "should return the release path with WorkingDir" $ \(deployPath, repoPath) -> do + (rpath, release) <- runHap $ do + release <- Hap.pushRelease $ mkTask deployPath repoPath + (,) <$> Hap.releasePath deployPath release (Just workingDir) + <*> pure release + + toFilePath rpath `shouldBe` toFilePath deployPath SF. releaseDir SF. renderRelease release SF. "working_dir" + describe "pushRelease" $ do it "sets up repo all right in Zsh" $ \(deployPath, repoPath) -> runHapWithShell Zsh $ do