Skip to content

Commit

Permalink
Updated test to be more backend/PK type agnostic.
Browse files Browse the repository at this point in the history
  • Loading branch information
naushadh committed Oct 3, 2018
1 parent e8e1b72 commit 95401b0
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions persistent-test/src/PersistentTest.hs
Expand Up @@ -26,6 +26,7 @@ import Data.Functor.Identity
import Data.Functor.Constant
import Data.Maybe (fromJust)
import qualified Data.HashMap.Lazy as M
import qualified Data.Map as Map
import Test.HUnit hiding (Test)
import Test.Hspec.Expectations ()
import Test.Hspec.QuickCheck(prop)
Expand Down Expand Up @@ -528,24 +529,21 @@ specs = describe "persistent" $ do

describe "repsertMany" $ do
it "adds new rows when no conflicts" $ db $ do
ids@[johnId, janeId, aliceId, eveId] <- replicateM 4 $ liftIO (Person1Key `fmap` generateKey)
let john = Person1 "john" 20
let jane = Person1 "jane" 18
let alice = Person1 "alice" 18
let eve = Person1 "eve" 19

johnId <- insert john
janeId <- insert jane
let (Right aliceId) = keyFromValues [PersistInt64 100]
let (Right eveId) = keyFromValues [PersistInt64 101]
insertKey johnId john
insertKey janeId jane

_ <- repsertMany [ (aliceId, alice), (eveId, eve) ]
(Just john') <- get johnId
(Just jane') <- get janeId
(Just alice') <- get aliceId
(Just eve') <- get eveId
es <- getMany ids

[john',jane',alice',eve'] @== [john,jane,alice,eve]
mapM_ delete [johnId, janeId, aliceId, eveId]
let rs = [john, jane, alice, eve]
es @== Map.fromList (zip ids rs)
mapM_ delete ids

it "handles conflicts by replacing old keys with new records" $ db $ do
let john = Person1 "john" 20
Expand Down

0 comments on commit 95401b0

Please sign in to comment.