27 date trunc postgres (#181)
* write test case * weird * better error message * rename, fix
This commit is contained in:
parent
b6279ca9f2
commit
9e643acb3d
@ -489,7 +489,11 @@ testAggregateFunctions = do
|
|||||||
|
|
||||||
testPostgresModule :: Spec
|
testPostgresModule :: Spec
|
||||||
testPostgresModule = do
|
testPostgresModule = do
|
||||||
|
<<<<<<< HEAD
|
||||||
|
describe "date_trunc" $ modifyMaxSuccess (`div` 10) $ do
|
||||||
|
=======
|
||||||
describe "date_trunc" $ do
|
describe "date_trunc" $ do
|
||||||
|
>>>>>>> master
|
||||||
prop "works" $ \listOfDateParts -> run $ do
|
prop "works" $ \listOfDateParts -> run $ do
|
||||||
let
|
let
|
||||||
utcTimes =
|
utcTimes =
|
||||||
@ -511,6 +515,9 @@ testPostgresModule = do
|
|||||||
for_ vals $ \(idx, utcTime) -> do
|
for_ vals $ \(idx, utcTime) -> do
|
||||||
insertKey idx (DateTruncTest utcTime)
|
insertKey idx (DateTruncTest utcTime)
|
||||||
|
|
||||||
|
-- Necessary to get the test to pass; see the discussion in
|
||||||
|
-- https://github.com/bitemyapp/esqueleto/pull/180
|
||||||
|
rawExecute "SET TIME ZONE 'UTC'" []
|
||||||
ret <-
|
ret <-
|
||||||
fmap (Map.fromList . coerce :: _ -> Map DateTruncTestId (UTCTime, UTCTime)) $
|
fmap (Map.fromList . coerce :: _ -> Map DateTruncTestId (UTCTime, UTCTime)) $
|
||||||
select $
|
select $
|
||||||
@ -526,14 +533,14 @@ testPostgresModule = do
|
|||||||
case Map.lookup idx ret of
|
case Map.lookup idx ret of
|
||||||
Nothing ->
|
Nothing ->
|
||||||
expectationFailure "index not found"
|
expectationFailure "index not found"
|
||||||
Just (original, expected) -> do
|
Just (original, truncated) -> do
|
||||||
utcTime `shouldBe` original
|
utcTime `shouldBe` original
|
||||||
if utctDay utcTime == utctDay expected
|
if utctDay utcTime == utctDay truncated
|
||||||
then
|
then
|
||||||
utctDay utcTime `shouldBe` utctDay expected
|
utctDay utcTime `shouldBe` utctDay truncated
|
||||||
else
|
else
|
||||||
-- use this if/else to get a beter error message
|
-- use this if/else to get a better error message
|
||||||
utcTime `shouldBe` expected
|
utcTime `shouldBe` truncated
|
||||||
|
|
||||||
describe "PostgreSQL module" $ do
|
describe "PostgreSQL module" $ do
|
||||||
describe "Aggregate functions" testAggregateFunctions
|
describe "Aggregate functions" testAggregateFunctions
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user