I have a set of Happstack.State MACID methods that I want to test using QuickCheck, but I'm having trouble figuring out the most elegant way to accomplish that. The problems I'm running into are:
- The only way to evaluate an
Evmonad computation is in theIOmonad viaqueryorupdate. - There's no way to create a purely in-memory MACID store; this is by design. Therefore, running things in the
IOmonad means there are temporary files to clean up after each test. - There's no way to initialize a new MACID store except with the
initialValuefor the state; it can't be generated viaArbitraryunless I expose an access method that replaces the state wholesale. - Working around all of the above means writing methods that only use features of
MonadReaderorMonadState(and running the test insideReaderorStateinstead ofEv. This means forgoing the use ofgetRandomorgetEventClockTimeand the like inside the method definitions.
The only options I can see are:
- Run the methods in a throw-away on-disk MACID store, cleaning up after each test and settling for starting from
initialValueeach time. - Write the methods to have most of the code run in a
MonadReaderorMonadState(which is more easily testable), and rely on a small amount of non-QuickCheck-able glue around it that callsgetRandomorgetEventClockTimeas necessary.
Is there a better solution that I'm overlooking?