added test for 48cae53
This commit is contained in:
parent
02fa5350fe
commit
f056f88088
17
test/Test.hs
17
test/Test.hs
@ -74,6 +74,10 @@ share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistUpperCase|
|
|||||||
frontcoverNumber Int
|
frontcoverNumber Int
|
||||||
Foreign Frontcover fkfrontcover frontcoverNumber
|
Foreign Frontcover fkfrontcover frontcoverNumber
|
||||||
deriving Eq Show
|
deriving Eq Show
|
||||||
|
Tag
|
||||||
|
name String
|
||||||
|
Primary name
|
||||||
|
deriving Eq Show
|
||||||
Article2
|
Article2
|
||||||
title String
|
title String
|
||||||
frontcoverId FrontcoverId
|
frontcoverId FrontcoverId
|
||||||
@ -256,13 +260,24 @@ main = do
|
|||||||
run $ do
|
run $ do
|
||||||
let fc = Frontcover number ""
|
let fc = Frontcover number ""
|
||||||
number = 101
|
number = 101
|
||||||
Right thePk = keyFromValues [PersistInt64 $ fromIntegral number]
|
Right thePk = keyFromValues [toPersistValue number]
|
||||||
fcPk <- insert fc
|
fcPk <- insert fc
|
||||||
[Entity _ ret] <- select $ from $ return
|
[Entity _ ret] <- select $ from $ return
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
ret `shouldBe` fc
|
ret `shouldBe` fc
|
||||||
fcPk `shouldBe` thePk
|
fcPk `shouldBe` thePk
|
||||||
|
|
||||||
|
it "works when returning a custom non-composite primary key from a query" $
|
||||||
|
run $ do
|
||||||
|
let name = "foo"
|
||||||
|
t = Tag name
|
||||||
|
Right thePk = keyFromValues [toPersistValue name]
|
||||||
|
tagPk <- insert t
|
||||||
|
[Value ret] <- select $ from $ \t' -> return (t'^.TagId)
|
||||||
|
liftIO $ do
|
||||||
|
ret `shouldBe` thePk
|
||||||
|
thePk `shouldBe` tagPk
|
||||||
|
|
||||||
it "works when returning a composite primary key from a query" $
|
it "works when returning a composite primary key from a query" $
|
||||||
pendingWith "Need to refactor 'Value a's SqlQuery instance"
|
pendingWith "Need to refactor 'Value a's SqlQuery instance"
|
||||||
{-
|
{-
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user