From ee87a66174faa29803351cb4fa63b69cfb456d16 Mon Sep 17 00:00:00 2001 From: James Crayne Date: Tue, 26 Apr 2016 00:32:16 -0400 Subject: make tests more independent --- testkiki/testkiki.hs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'testkiki') diff --git a/testkiki/testkiki.hs b/testkiki/testkiki.hs index 4483368..452d298 100644 --- a/testkiki/testkiki.hs +++ b/testkiki/testkiki.hs @@ -73,29 +73,34 @@ doTests tkConfig = hspec $ do -- **** kiki tests ***** describe "kiki init" $ do it "honors GNUPGHOME environment variable" $ do - let kiki = kiki'Env tkConfig + let kiki = kiki'Env cfg + cfg = appendpaths tkConfig "0" (isInfixOf "New packet" <$> kiki ["init"]) `shouldReturn` True it "creates parent directories with --gnupghome" $ do - let home = chroot tkConfig "home" "tester" - kiki = kiki'Env'And'HomeArg tkConfig - { gnupghome = home ".gnupg" } + let home = chroot cfg "home" "tester" + cfg = appendpaths tkConfig "1" + kiki = kiki'Env'And'HomeArg cfg + { gnupghome = home ".gnupg" } output <- kiki ["init"] b <- doesDirectoryExist home - (isInfixOf "New packet" output && b ) `shouldBe` True + -- isInfixOf "New packet" output + b `shouldBe` True it "creates new secring honoring GNUPGHOME" $ do - let kiki = kiki'Env'And'HomeArg tkConfig + let cfg = appendpaths tkConfig "2" + let kiki = kiki'Env'And'HomeArg cfg output <- kiki ["init"] - b <- doesFileExist (chroot tkConfig gnupghome tkConfig "secring.gpg") + b <- doesFileExist (chroot cfg gnupghome cfg "secring.gpg") (isInfixOf "New packet" output && b ) `shouldBe` True it "creates new secring in /root/.gnupg" $ do - let kiki = kiki'No'Env'No'Home tkConfig + let cfg = appendpaths tkConfig "3" + let kiki = kiki'No'Env'No'Home cfg unsetEnv "GNUPGHOME" - createDirectoryIfMissing True (chroot tkConfig "root" ".gnupg") + createDirectoryIfMissing True (chroot cfg "root" ".gnupg") output <- kiki ["init"] - let p = (chroot tkConfig "root" ".gnupg" "secring.gpg") + let p = (chroot cfg "root" ".gnupg" "secring.gpg") putStrLn $ "Does exist? " ++ show p b <- doesFileExist p -- (isInfixOf "New packet" output && b ) @@ -166,3 +171,6 @@ doTests tkConfig = hspec $ do isInfixOf sub str = let (_,match) = B.breakSubstring (B.pack sub) (B.pack str) in not (B.null match) + appendpaths config str = TKS { gnupghome = gnupghome config ++ str + , chroot = chroot config ++ str + } -- cgit v1.2.3