diff options
author | James Crayne <jim.crayne@gmail.com> | 2016-04-26 00:32:16 -0400 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2016-04-26 06:04:05 -0400 |
commit | ee87a66174faa29803351cb4fa63b69cfb456d16 (patch) | |
tree | 5f84c80eaf7c0755bd68a1eb7f469f272d5217b0 | |
parent | 1741bb13f18f6236225b00de8baac8a7a9eaed56 (diff) |
make tests more independent
-rw-r--r-- | testkiki/testkiki.hs | 28 |
1 files changed, 18 insertions, 10 deletions
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 | |||
73 | -- **** kiki tests ***** | 73 | -- **** kiki tests ***** |
74 | describe "kiki init" $ do | 74 | describe "kiki init" $ do |
75 | it "honors GNUPGHOME environment variable" $ do | 75 | it "honors GNUPGHOME environment variable" $ do |
76 | let kiki = kiki'Env tkConfig | 76 | let kiki = kiki'Env cfg |
77 | cfg = appendpaths tkConfig "0" | ||
77 | (isInfixOf "New packet" <$> kiki ["init"]) `shouldReturn` True | 78 | (isInfixOf "New packet" <$> kiki ["init"]) `shouldReturn` True |
78 | 79 | ||
79 | it "creates parent directories with --gnupghome" $ do | 80 | it "creates parent directories with --gnupghome" $ do |
80 | let home = chroot tkConfig </> "home" </> "tester" | 81 | let home = chroot cfg </> "home" </> "tester" |
81 | kiki = kiki'Env'And'HomeArg tkConfig | 82 | cfg = appendpaths tkConfig "1" |
82 | { gnupghome = home </> ".gnupg" } | 83 | kiki = kiki'Env'And'HomeArg cfg |
84 | { gnupghome = home </> ".gnupg" } | ||
83 | output <- kiki ["init"] | 85 | output <- kiki ["init"] |
84 | b <- doesDirectoryExist home | 86 | b <- doesDirectoryExist home |
85 | (isInfixOf "New packet" output && b ) `shouldBe` True | 87 | -- isInfixOf "New packet" output |
88 | b `shouldBe` True | ||
86 | 89 | ||
87 | it "creates new secring honoring GNUPGHOME" $ do | 90 | it "creates new secring honoring GNUPGHOME" $ do |
88 | let kiki = kiki'Env'And'HomeArg tkConfig | 91 | let cfg = appendpaths tkConfig "2" |
92 | let kiki = kiki'Env'And'HomeArg cfg | ||
89 | output <- kiki ["init"] | 93 | output <- kiki ["init"] |
90 | b <- doesFileExist (chroot tkConfig </> gnupghome tkConfig </> "secring.gpg") | 94 | b <- doesFileExist (chroot cfg </> gnupghome cfg </> "secring.gpg") |
91 | (isInfixOf "New packet" output && b ) `shouldBe` True | 95 | (isInfixOf "New packet" output && b ) `shouldBe` True |
92 | 96 | ||
93 | it "creates new secring in /root/.gnupg" $ do | 97 | it "creates new secring in /root/.gnupg" $ do |
94 | let kiki = kiki'No'Env'No'Home tkConfig | 98 | let cfg = appendpaths tkConfig "3" |
99 | let kiki = kiki'No'Env'No'Home cfg | ||
95 | unsetEnv "GNUPGHOME" | 100 | unsetEnv "GNUPGHOME" |
96 | createDirectoryIfMissing True (chroot tkConfig </> "root" </> ".gnupg") | 101 | createDirectoryIfMissing True (chroot cfg </> "root" </> ".gnupg") |
97 | output <- kiki ["init"] | 102 | output <- kiki ["init"] |
98 | let p = (chroot tkConfig </> "root" </> ".gnupg" </> "secring.gpg") | 103 | let p = (chroot cfg </> "root" </> ".gnupg" </> "secring.gpg") |
99 | putStrLn $ "Does exist? " ++ show p | 104 | putStrLn $ "Does exist? " ++ show p |
100 | b <- doesFileExist p | 105 | b <- doesFileExist p |
101 | -- (isInfixOf "New packet" output && b ) | 106 | -- (isInfixOf "New packet" output && b ) |
@@ -166,3 +171,6 @@ doTests tkConfig = hspec $ do | |||
166 | isInfixOf sub str = let (_,match) = B.breakSubstring (B.pack sub) (B.pack str) | 171 | isInfixOf sub str = let (_,match) = B.breakSubstring (B.pack sub) (B.pack str) |
167 | in not (B.null match) | 172 | in not (B.null match) |
168 | 173 | ||
174 | appendpaths config str = TKS { gnupghome = gnupghome config ++ str | ||
175 | , chroot = chroot config ++ str | ||
176 | } | ||