Skip to content

Instantly share code, notes, and snippets.

@tazjin
Created August 7, 2018 10:53
Show Gist options
  • Save tazjin/05436eff4f0238a47a7c239c9f360a9a to your computer and use it in GitHub Desktop.
Save tazjin/05436eff4f0238a47a7c239c9f360a9a to your computer and use it in GitHub Desktop.
-- | Test something with an in-memory acid-state
acidTest :: forall state event query result.
(IsAcidic state, UpdateEvent event, MethodState event ~ state,
QueryEvent query, MethodState query ~ state,
MethodResult query ~ result)
=> String -- ^ Test description
-> state -- ^ Initial state for test
-> event -- ^ Event to test
-> query -- ^ Query to check
-> (result -> Bool) -- ^ Function to test query result
-> Assertion
acidTest desc initialState event query' checker = do
state <- openMemoryState initialState
update state event
result <- query state query'
assertBool desc $ checker result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment