serial-test-generators 0.1.2 → 0.1.3
raw patch · 2 files changed
+15/−7 lines, 2 filesdep +here
Dependencies added: here
Files
- serial-test-generators.cabal +3/−1
- src/Test/Serial.hs +12/−6
serial-test-generators.cabal view
@@ -1,5 +1,5 @@ Name: serial-test-generators-Version: 0.1.2+Version: 0.1.3 Author: Scott <scottmurphy09@gmail.com> Maintainer: Scott <scottmurphy09@gmail.com> License: MIT@@ -26,6 +26,7 @@ , binary >= 0.6.3.0 , cereal >= 0.3.5.0 , bytestring >= 0.9.0+ , here Test-Suite spec@@ -44,6 +45,7 @@ , bytestring , transformers >= 0.3.0 , system-fileio+ , here Source-Repository head
src/Test/Serial.hs view
@@ -1,3 +1,7 @@+{-# LANGUAGE TemplateHaskell #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE QuasiQuotes #-} {- | Module : Test.Serial Description : Test.Serial run serialization tests against static files@@ -11,9 +15,6 @@ -} -{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE DeriveGeneric #-}- module Test.Serial (runAesonSerializationTest , runBinarySerializationTest , runCerealSerializationTest@@ -25,6 +26,7 @@ import qualified Data.ByteString as BStrict import qualified Data.ByteString.Lazy as BLazy import GHC.Generics+import Data.String.Here.Interpolated (i) import System.IO (withFile, IOMode(..),hIsEOF) -------------------------------------------------- @@ -65,13 +67,18 @@ (Right a) |(A.toJSON . makeMockAesonInference $ a) == (A.toJSON.makeMockAesonInference $ dataUnderTest) -> return . Right $ a- |otherwise -> return . Left . AesonError $ "Serializations do not match"- + |otherwise -> return . Left . AesonError . explainError (A.toJSON . makeMockAesonInference $ a) $ (A.toJSON . makeMockAesonInference $ dataUnderTest)+ writeOutputAndExit h = do putStrLn "file not found, writing given serialization to disk, rerun tests" BLazy.hPut h $ A.encode dataUnderTest return . Left $ NoFileFound +explainError old new = [i|+ JSON doesn't match: + old: ${old}+ new: ${new}+ |] @@ -146,5 +153,4 @@ putStrLn "file not found, writing given serialization to disk, rerun tests" BStrict.hPut h $ C.encode dataUnderTest return . Left $ NoFileFound-