Skip to content

Commit

Permalink
Make tests more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
tchoutri committed Sep 28, 2024
1 parent e25df1d commit 5b0edfd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 1 addition & 3 deletions pg-entity.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ maintainer: Théophile Choutri
category: Database
license: MIT
build-type: Simple
tested-with:
GHC ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2

tested-with: GHC ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2
extra-source-files:
CHANGELOG.md
LICENSE.md
Expand Down
8 changes: 7 additions & 1 deletion test/EntitySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ import Database.PostgreSQL.Entity.DBT (QueryNature (..), query)
import Database.PostgreSQL.Simple (Only (Only))
import Database.PostgreSQL.Transact (DBT)

import qualified Data.Map as Map
import Data.Maybe (fromJust)
import qualified Data.Set as S
import qualified Data.Set as Set
import Data.Vector (Vector)
import qualified Data.Vector as Vector
import Database.PostgreSQL.Entity.Types
import Optics.Core
import Test.Tasty
Expand Down Expand Up @@ -132,7 +134,11 @@ getAllTitlesByAuthorName = do
_joinSelectWithFields @BlogPost @Author [[field| title |]] [[field| name |]]
<> _where [[field| name |]]
result <- liftDB (query Select q (Only ("Hansi Kürsch" :: Text)) :: MonadIO m => DBT m (Vector (Text, Text)))
U.assertEqual [("The Script for my requiem", "Hansi Kürsch"), ("Mordred's Song", "Hansi Kürsch")] result
let actualMap = Map.fromList $ Vector.toList result
let expectedMap = Map.fromList [("The Script for my requiem", "Hansi Kürsch"), ("Mordred's Song", "Hansi Kürsch")]
U.assertEqual
expectedMap
actualMap

changeAuthorName :: TestM ()
changeAuthorName = do
Expand Down

0 comments on commit 5b0edfd

Please sign in to comment.