user-management/test/UserManagerSpec.hs
2024-05-25 20:14:01 +02:00

38 lines
1.3 KiB
Haskell

module UserManagerSpec (main, spec) where
-- Main entry point for the specs
main :: IO ()
main = hspec spec
-- Specs for the UserManager module
spec :: Spec
spec = before_ initializeDB $ do
-- Specs for the UserManager functions
describe "UserManager" $ do
-- Specs for the addUser function
it "should add and list users" $ do
-- Create a user and list all users
addUser "testUser" "testUser@example.com"
users <- listUsers
-- Check that the user was added
users `shouldContain` [User "testUser" "testUser@example.com"]
-- Specs for the findUser function
it "should find a user" $ do
-- Create a user and search for them
addUser "findUser" "findUser@example.com"
user <- findUser "findUser"
-- Check that the user was found
user `shouldBe` Just (User "findUser" "findUser@example.com")
-- Specs for the deleteUser function
it "should delete a user" $ do
-- Create a user and delete them
addUser "deleteUser" "deleteUser@example.com"
deleteUser "deleteUser"
-- Check that the user was deleted
user <- findUser "deleteUser"
user `shouldBe` Nothing