serversession-1.0.3: Secure, modular server-side sessions.
Safe HaskellNone
LanguageHaskell2010

Web.ServerSession.Core.StorageTests

Description

This module contains tests that should pass for every storage backend. These are not intended for end-users of the serversession library. However, they are part of the supported API, so they're not an Internal module.

Synopsis

Documentation

allStorageTests Source #

Arguments

:: forall m sto. (Monad m, Storage sto, SessionData sto ~ SessionMap) 
=> sto

Storage backend.

-> (String -> IO () -> m ())

hspec's it.

-> (forall a. IO a -> m a)

hspec's runIO.

-> (m () -> m ())

hspec's parallel

-> (forall a. (Show a, Eq a) => a -> a -> IO ())

hspec's shouldBe.

-> (forall a. (Show a, Eq a) => IO a -> a -> IO ())

hspec's shouldReturn.

-> (forall a e. Exception e => IO a -> (e -> Bool) -> IO ())

hspec's shouldThrow.

-> m () 

Execute all storage tests using SessionMap.

This function is meant to be used with hspec. However, we don't want to depend on hspec, so it takes the relevant hspec functions as arguments. Here's how it should be called:

allStorageTests myStorageBackend it runIO parallel shouldBe shouldReturn shouldThrow

Some storage backends are difficult to test with a clean slate. For this reason, this collection of tests works with unclean storage backends. In order to enforce these claims, we always test with an unclean storage backend by getting a single reference to it instead of asking for a function that creates storage backends and calling it on every test.

In addition, this test suite can be executed in parallel, there are no dependencies between tests. However, some tests require a large amount of memory so we try to run them sequentially in order to reduce the peak memory usage of the test suite.