Skip to content

Commit

Permalink
WIP: exception testing
Browse files Browse the repository at this point in the history
  • Loading branch information
memowe committed Aug 13, 2024
1 parent d5796a6 commit 89228a0
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions test/LiBro/Data/StorageSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,8 @@ personStorage :: Spec
personStorage = describe "XLSX storage of Person data" $ do

describe "Loading without a file" $ do
result <- runIO $ withSystemTempDirectory "person-storage" $ \tdir -> do
let config = def { storage = def { directory = tdir }}
runLiBroIO config loadPersons
it "Empty Person map" $
result `shouldBe` M.empty
it "Correct error thrown" $
emptyPersonLoading `shouldThrow` anyException

modifyMaxSuccess (const 20) $
prop "Load . store = id" $
Expand All @@ -147,15 +144,17 @@ personStorage = describe "XLSX storage of Person data" $ do
loadedPersons <- runLiBroIO config $ storePersons pmap >> loadPersons
return $ loadedPersons === pmap

where emptyPersonLoading = do
withSystemTempDirectory "person-storage" $ \tdir -> do
let config = def { storage = def { directory = tdir }}
runLiBroIO config loadPersons

taskStorage :: Spec
taskStorage = describe "XLSX storage of Task data" $ do

describe "Loading without a file" $ do
result <- runIO $ withSystemTempDirectory "task-storage" $ \tdir -> do
let config = def { storage = def { directory = tdir }}
runLiBroIO config $ loadTasks M.empty
it "Empty task list" $
result `shouldBe` []
it "Correct error thrown" $
emptyTaskLoading `shouldThrow` anyException

let pmap = personMap
[ Person 17 "Nina Schreubenmyrthe" "foo@bar"
Expand Down Expand Up @@ -183,6 +182,11 @@ taskStorage = describe "XLSX storage of Task data" $ do
it "Got the right task forest" $
loadedTasks `shouldBe` ts

where emptyTaskLoading = do
withSystemTempDirectory "task-storage" $ \tdir -> do
let config = def { storage = def { directory = tdir }}
runLiBroIO config $ loadTasks M.empty

dataStorage :: Spec
dataStorage = describe "Complete dataset" $ do

Expand Down

0 comments on commit 89228a0

Please sign in to comment.