Revision be0cb2d7 test/hs/Test/Ganeti/JQueue.hs
b/test/hs/Test/Ganeti/JQueue.hs | ||
---|---|---|
176 | 176 |
-- | Tests listing of Job ids. |
177 | 177 |
prop_ListJobIDs :: Property |
178 | 178 |
prop_ListJobIDs = monadicIO $ do |
179 |
let extractJobIDs jIDs = do |
|
180 |
either_jobs <- jIDs |
|
181 |
case either_jobs of |
|
182 |
Right j -> return j |
|
183 |
Left e -> fail $ show e |
|
184 |
isLeft e = |
|
185 |
case e of |
|
186 |
Left _ -> True |
|
187 |
_ -> False |
|
179 | 188 |
jobs <- pick $ resize 10 (listOf1 genJobId `suchThat` (\l -> l == nub l)) |
180 | 189 |
(e, f, g) <- |
181 | 190 |
run . withSystemTempDirectory "jqueue-test." $ \tempdir -> do |
182 |
empty_dir <- getJobIDs [tempdir] |
|
191 |
empty_dir <- extractJobIDs $ getJobIDs [tempdir]
|
|
183 | 192 |
mapM_ (\jid -> writeFile (tempdir </> jobFileName jid) "") jobs |
184 |
full_dir <- getJobIDs [tempdir] |
|
193 |
full_dir <- extractJobIDs $ getJobIDs [tempdir]
|
|
185 | 194 |
invalid_dir <- getJobIDs [tempdir </> "no-such-dir"] |
186 | 195 |
return (empty_dir, sortJobIDs full_dir, invalid_dir) |
187 | 196 |
stop $ conjoin [ printTestCase "empty directory" $ e ==? [] |
188 | 197 |
, printTestCase "directory with valid names" $ |
189 | 198 |
f ==? sortJobIDs jobs |
190 |
, printTestCase "invalid directory" $ g ==? []
|
|
199 |
, printTestCase "invalid directory" $ isLeft g
|
|
191 | 200 |
] |
192 | 201 |
|
193 | 202 |
-- | Tests loading jobs from disk. |
Also available in: Unified diff