From 2ed58e36597347d81215c167c9f29e832753dbf2 Mon Sep 17 00:00:00 2001 From: parsonsmatt Date: Mon, 29 Mar 2021 13:14:27 -0600 Subject: [PATCH] ok no really --- test/MySQL/Test.hs | 16 +++++----------- test/PostgreSQL/Test.hs | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/test/MySQL/Test.hs b/test/MySQL/Test.hs index d74535b..5541fbf 100644 --- a/test/MySQL/Test.hs +++ b/test/MySQL/Test.hs @@ -7,6 +7,8 @@ module Main (main) where +import Control.Applicative +import System.Environment import Control.Monad (void) import Control.Monad.IO.Class (MonadIO(liftIO)) import Control.Monad.Logger (runStderrLoggingT, runNoLoggingT) @@ -238,7 +240,7 @@ migrateIt = do withConn :: RunDbMonad m => (SqlBackend -> R.ResourceT m a) -> m a withConn f = do - ci <- isCI + ci <- liftIO isCI let connInfo | ci = defaultConnectInfo @@ -256,19 +258,11 @@ withConn f = do , connectDatabase = "esqutest" , connectPort = 3306 } - R.runResourceT $ - withMySQLConn defaultConnectInfo - { connectHost = "localhost" - , connectUser = "travis" - , connectPassword = "esqutest" - , connectDatabase = "esqutest" - , connectPort = 3306 - } - f + R.runResourceT $ withMySQLConn connInfo f isCI :: IO Bool isCI = do - env <- liftIO getEnvironment + env <- getEnvironment return $ case lookup "TRAVIS" env <|> lookup "CI" env of Just "true" -> True _ -> False diff --git a/test/PostgreSQL/Test.hs b/test/PostgreSQL/Test.hs index 89563b5..d608187 100644 --- a/test/PostgreSQL/Test.hs +++ b/test/PostgreSQL/Test.hs @@ -729,7 +729,7 @@ testInclusion = do describe "@>" $ do it "creates sane SQL" $ do let obj = object ["a" .= False, "b" .= True] - encoded = BSL.toStrct $ encode obj + encoded = BSL.toStrict $ encode obj createSaneSQL (jsonbVal obj @>. jsonbVal (object ["a" .= False])) "SELECT (? @> ?)\nFROM \"Json\"\n" @@ -738,7 +738,7 @@ testInclusion = do ] it "creates sane SQL (chained)" $ do let obj = object ["a" .= [object ["b" .= True]]] - encoded = BSL.toStrct $ encode obj + encoded = BSL.toStrict $ encode obj createSaneSQL (jsonbVal obj ->. "a" @>. jsonbVal (object ["b" .= True])) "SELECT ((? -> ?) @> ?)\nFROM \"Json\"\n" @@ -754,9 +754,9 @@ testInclusion = do liftIO $ length y `shouldBe` 1 liftIO $ length z `shouldBe` 1 describe "<@" $ do - it "creates sane SQL" $ + it "creates sane SQL" $ do let obj = object ["a" .= False, "b" .= True] - encoded = BSL.toStrct $ encode obj + encoded = BSL.toStrict $ encode obj createSaneSQL (jsonbVal (object ["a" .= False]) <@. jsonbVal obj ) "SELECT (? <@ ?)\nFROM \"Json\"\n" @@ -826,7 +826,7 @@ testQMarkAny = do ] it "creates sane SQL (chained)" $ do let obj = object ["a" .= [object ["b" .= True]]] - encoded = BSL.toStrct $ encode obj + encoded = BSL.toStrict $ encode obj createSaneSQL (jsonbVal obj #>. ["a","0"] ?|. ["b","c"]) "SELECT ((? #> ?) ??| ?)\nFROM \"Json\"\n" @@ -849,7 +849,7 @@ testQMarkAll = do describe "Question Mark (All)" $ do it "creates sane SQL" $ do let obj = object ["a" .= False, "b" .= True] - encoded = BSL.toStrct $ encode obj + encoded = BSL.toStrict $ encode obj createSaneSQL (jsonbVal obj ?&. ["a","c"]) "SELECT (? ??& ?)\nFROM \"Json\"\n" @@ -858,7 +858,7 @@ testQMarkAll = do ] it "creates sane SQL (chained)" $ do let obj = object ["a" .= [object ["b" .= True]]] - encoded = BSL.toStrct $ encode obj + encoded = BSL.toStrict $ encode obj createSaneSQL (jsonbVal obj #>. ["a","0"] ?&. ["b","c"]) "SELECT ((? #> ?) ??& ?)\nFROM \"Json\"\n" @@ -899,7 +899,7 @@ testConcatenationOperator = do ] it "creates sane SQL (chained)" $ do let obj = object ["a" .= [object ["b" .= True]]] - encoded = BSL.toStrct $ encode obj + encoded = BSL.toStrict $ encode obj createSaneSQL @JSONValue (jsonbVal obj ->. "a" JSON.||. jsonbVal (toJSON [Null])) "SELECT ((? -> ?) || ?)\nFROM \"Json\"\n" @@ -976,7 +976,7 @@ testMinusOperatorV10 = do describe "Minus Operator (PSQL >= v10)" $ do it "creates sane SQL" $ do let obj = object ["a" .= False, "b" .= True] - encoded = BSL.toStrct $ encode obj + encoded = BSL.toStrict $ encode obj createSaneSQL @JSONValue (jsonbVal obj --. ["a","b"]) "SELECT (? - ?)\nFROM \"Json\"\n" @@ -985,7 +985,7 @@ testMinusOperatorV10 = do ] it "creates sane SQL (chained)" $ do let obj = object ["a" .= [object ["b" .= True]]] - encoded = BSL.toStrct $ encode obj + encoded = BSL.toStrict $ encode obj createSaneSQL @JSONValue (jsonbVal obj #>. ["a","0"] --. ["b"]) "SELECT ((? #> ?) - ?)\nFROM \"Json\"\n"