module Merge.UtilsSpec (spec) where import Test.Hspec import Error import Merge.Utils import Portage.PackageId import qualified Distribution.Package as Cabal spec :: Spec spec = do describe "(<.>)" $ do it "adds a dot (.) between two strings" $ do "foo" <.> "bar" `shouldBe` "foo.bar" describe "readPackageString" $ do context "when the package string is valid" $ do it "returns a Right tuple containing the parsed information" $ do readPackageString ["dev-haskell/packagename1-1.0.0"] `shouldBe` Right ( Just (Category "dev-haskell") , Cabal.mkPackageName "packagename1" , Just (Version [1,0,0] Nothing [] 0) ) context "when the package string is empty" $ do it "returns a Left HackPortError" $ do readPackageString [] `shouldBe` Left (ArgumentError "Need an argument, [category/]package[-version]") context "when the package string contains too many arguments" $ do it "returns a Left HackPortError" $ do let args = ["dev-haskell/packagename1-1.0.0", "dev-haskell/packagename2-1.0.0"] readPackageString args `shouldBe` Left (ArgumentError ("Too many arguments: " ++ unwords args)) -- describe "getPreviousPackageId" $ do -- it "returns the PackageId of the previous version" $ do -- let ebuildDir = [ "foo-bar2-3.0.0b_rc2-r1.ebuild" -- , "foo-bar2-3.0.0b_rc2-r2.ebuild" -- , "foo-bar2-3.0.1.ebuild" -- , "metadata.xml" -- , "Manifest" -- , "files" -- ] -- newPkgId = PackageId (PackageName (Category "dev-haskell") -- (Cabal.mkPackageName "foo-bar2")) -- Version