Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
newtype LanguageDBState = LanguageDBState { expandState :: (String, [LoadedEntity Language]) }
deriving (Show)
instance Arbitrary LanguageDBState where
arbitrary =
elements [
LanguageDBState
( [str| INSERT INTO language (iso_code, name) VALUES ('eng', 'English') |]
, [Entity { entityRef = Ref (toSql ("eng" :: String))
, entityInfo = Language { languageName = "English"
, languageIsoCode = "eng" } }]
)
]
prop_language_allLanguages = monadicIO $ do
(sql, languages) <- expandState `fmap` (pick arbitrary :: PropertyM IO LanguageDBState)
fetched <- run $ databaseTest $ (runRaw sql >> allLanguages)
assert $ fetched == languages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment