From 9e643acb3db26d379844cbccf28c116ee5734f66 Mon Sep 17 00:00:00 2001 From: Matt Parsons Date: Mon, 30 Mar 2020 12:55:19 -0600 Subject: [PATCH] 27 date trunc postgres (#181) * write test case * weird * better error message * rename, fix --- test/PostgreSQL/Test.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/PostgreSQL/Test.hs b/test/PostgreSQL/Test.hs index 8b561e6..7200226 100644 --- a/test/PostgreSQL/Test.hs +++ b/test/PostgreSQL/Test.hs @@ -489,7 +489,11 @@ testAggregateFunctions = do testPostgresModule :: Spec testPostgresModule = do +<<<<<<< HEAD + describe "date_trunc" $ modifyMaxSuccess (`div` 10) $ do +======= describe "date_trunc" $ do +>>>>>>> master prop "works" $ \listOfDateParts -> run $ do let utcTimes = @@ -511,6 +515,9 @@ testPostgresModule = do for_ vals $ \(idx, utcTime) -> do 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 <- fmap (Map.fromList . coerce :: _ -> Map DateTruncTestId (UTCTime, UTCTime)) $ select $ @@ -526,14 +533,14 @@ testPostgresModule = do case Map.lookup idx ret of Nothing -> expectationFailure "index not found" - Just (original, expected) -> do + Just (original, truncated) -> do utcTime `shouldBe` original - if utctDay utcTime == utctDay expected + if utctDay utcTime == utctDay truncated then - utctDay utcTime `shouldBe` utctDay expected + utctDay utcTime `shouldBe` utctDay truncated else - -- use this if/else to get a beter error message - utcTime `shouldBe` expected + -- use this if/else to get a better error message + utcTime `shouldBe` truncated describe "PostgreSQL module" $ do describe "Aggregate functions" testAggregateFunctions