ok no really

This commit is contained in:
parsonsmatt 2021-03-29 13:14:27 -06:00
parent d2d52566bb
commit 2ed58e3659
2 changed files with 15 additions and 21 deletions

View File

@ -7,6 +7,8 @@
module Main (main) where module Main (main) where
import Control.Applicative
import System.Environment
import Control.Monad (void) import Control.Monad (void)
import Control.Monad.IO.Class (MonadIO(liftIO)) import Control.Monad.IO.Class (MonadIO(liftIO))
import Control.Monad.Logger (runStderrLoggingT, runNoLoggingT) import Control.Monad.Logger (runStderrLoggingT, runNoLoggingT)
@ -238,7 +240,7 @@ migrateIt = do
withConn :: RunDbMonad m => (SqlBackend -> R.ResourceT m a) -> m a withConn :: RunDbMonad m => (SqlBackend -> R.ResourceT m a) -> m a
withConn f = do withConn f = do
ci <- isCI ci <- liftIO isCI
let connInfo let connInfo
| ci = | ci =
defaultConnectInfo defaultConnectInfo
@ -256,19 +258,11 @@ withConn f = do
, connectDatabase = "esqutest" , connectDatabase = "esqutest"
, connectPort = 3306 , connectPort = 3306
} }
R.runResourceT $ R.runResourceT $ withMySQLConn connInfo f
withMySQLConn defaultConnectInfo
{ connectHost = "localhost"
, connectUser = "travis"
, connectPassword = "esqutest"
, connectDatabase = "esqutest"
, connectPort = 3306
}
f
isCI :: IO Bool isCI :: IO Bool
isCI = do isCI = do
env <- liftIO getEnvironment env <- getEnvironment
return $ case lookup "TRAVIS" env <|> lookup "CI" env of return $ case lookup "TRAVIS" env <|> lookup "CI" env of
Just "true" -> True Just "true" -> True
_ -> False _ -> False

View File

@ -729,7 +729,7 @@ testInclusion = do
describe "@>" $ do describe "@>" $ do
it "creates sane SQL" $ do it "creates sane SQL" $ do
let obj = object ["a" .= False, "b" .= True] let obj = object ["a" .= False, "b" .= True]
encoded = BSL.toStrct $ encode obj encoded = BSL.toStrict $ encode obj
createSaneSQL createSaneSQL
(jsonbVal obj @>. jsonbVal (object ["a" .= False])) (jsonbVal obj @>. jsonbVal (object ["a" .= False]))
"SELECT (? @> ?)\nFROM \"Json\"\n" "SELECT (? @> ?)\nFROM \"Json\"\n"
@ -738,7 +738,7 @@ testInclusion = do
] ]
it "creates sane SQL (chained)" $ do it "creates sane SQL (chained)" $ do
let obj = object ["a" .= [object ["b" .= True]]] let obj = object ["a" .= [object ["b" .= True]]]
encoded = BSL.toStrct $ encode obj encoded = BSL.toStrict $ encode obj
createSaneSQL createSaneSQL
(jsonbVal obj ->. "a" @>. jsonbVal (object ["b" .= True])) (jsonbVal obj ->. "a" @>. jsonbVal (object ["b" .= True]))
"SELECT ((? -> ?) @> ?)\nFROM \"Json\"\n" "SELECT ((? -> ?) @> ?)\nFROM \"Json\"\n"
@ -754,9 +754,9 @@ testInclusion = do
liftIO $ length y `shouldBe` 1 liftIO $ length y `shouldBe` 1
liftIO $ length z `shouldBe` 1 liftIO $ length z `shouldBe` 1
describe "<@" $ do describe "<@" $ do
it "creates sane SQL" $ it "creates sane SQL" $ do
let obj = object ["a" .= False, "b" .= True] let obj = object ["a" .= False, "b" .= True]
encoded = BSL.toStrct $ encode obj encoded = BSL.toStrict $ encode obj
createSaneSQL createSaneSQL
(jsonbVal (object ["a" .= False]) <@. jsonbVal obj ) (jsonbVal (object ["a" .= False]) <@. jsonbVal obj )
"SELECT (? <@ ?)\nFROM \"Json\"\n" "SELECT (? <@ ?)\nFROM \"Json\"\n"
@ -826,7 +826,7 @@ testQMarkAny = do
] ]
it "creates sane SQL (chained)" $ do it "creates sane SQL (chained)" $ do
let obj = object ["a" .= [object ["b" .= True]]] let obj = object ["a" .= [object ["b" .= True]]]
encoded = BSL.toStrct $ encode obj encoded = BSL.toStrict $ encode obj
createSaneSQL createSaneSQL
(jsonbVal obj #>. ["a","0"] ?|. ["b","c"]) (jsonbVal obj #>. ["a","0"] ?|. ["b","c"])
"SELECT ((? #> ?) ??| ?)\nFROM \"Json\"\n" "SELECT ((? #> ?) ??| ?)\nFROM \"Json\"\n"
@ -849,7 +849,7 @@ testQMarkAll = do
describe "Question Mark (All)" $ do describe "Question Mark (All)" $ do
it "creates sane SQL" $ do it "creates sane SQL" $ do
let obj = object ["a" .= False, "b" .= True] let obj = object ["a" .= False, "b" .= True]
encoded = BSL.toStrct $ encode obj encoded = BSL.toStrict $ encode obj
createSaneSQL createSaneSQL
(jsonbVal obj ?&. ["a","c"]) (jsonbVal obj ?&. ["a","c"])
"SELECT (? ??& ?)\nFROM \"Json\"\n" "SELECT (? ??& ?)\nFROM \"Json\"\n"
@ -858,7 +858,7 @@ testQMarkAll = do
] ]
it "creates sane SQL (chained)" $ do it "creates sane SQL (chained)" $ do
let obj = object ["a" .= [object ["b" .= True]]] let obj = object ["a" .= [object ["b" .= True]]]
encoded = BSL.toStrct $ encode obj encoded = BSL.toStrict $ encode obj
createSaneSQL createSaneSQL
(jsonbVal obj #>. ["a","0"] ?&. ["b","c"]) (jsonbVal obj #>. ["a","0"] ?&. ["b","c"])
"SELECT ((? #> ?) ??& ?)\nFROM \"Json\"\n" "SELECT ((? #> ?) ??& ?)\nFROM \"Json\"\n"
@ -899,7 +899,7 @@ testConcatenationOperator = do
] ]
it "creates sane SQL (chained)" $ do it "creates sane SQL (chained)" $ do
let obj = object ["a" .= [object ["b" .= True]]] let obj = object ["a" .= [object ["b" .= True]]]
encoded = BSL.toStrct $ encode obj encoded = BSL.toStrict $ encode obj
createSaneSQL @JSONValue createSaneSQL @JSONValue
(jsonbVal obj ->. "a" JSON.||. jsonbVal (toJSON [Null])) (jsonbVal obj ->. "a" JSON.||. jsonbVal (toJSON [Null]))
"SELECT ((? -> ?) || ?)\nFROM \"Json\"\n" "SELECT ((? -> ?) || ?)\nFROM \"Json\"\n"
@ -976,7 +976,7 @@ testMinusOperatorV10 = do
describe "Minus Operator (PSQL >= v10)" $ do describe "Minus Operator (PSQL >= v10)" $ do
it "creates sane SQL" $ do it "creates sane SQL" $ do
let obj = object ["a" .= False, "b" .= True] let obj = object ["a" .= False, "b" .= True]
encoded = BSL.toStrct $ encode obj encoded = BSL.toStrict $ encode obj
createSaneSQL @JSONValue createSaneSQL @JSONValue
(jsonbVal obj --. ["a","b"]) (jsonbVal obj --. ["a","b"])
"SELECT (? - ?)\nFROM \"Json\"\n" "SELECT (? - ?)\nFROM \"Json\"\n"
@ -985,7 +985,7 @@ testMinusOperatorV10 = do
] ]
it "creates sane SQL (chained)" $ do it "creates sane SQL (chained)" $ do
let obj = object ["a" .= [object ["b" .= True]]] let obj = object ["a" .= [object ["b" .= True]]]
encoded = BSL.toStrct $ encode obj encoded = BSL.toStrict $ encode obj
createSaneSQL @JSONValue createSaneSQL @JSONValue
(jsonbVal obj #>. ["a","0"] --. ["b"]) (jsonbVal obj #>. ["a","0"] --. ["b"])
"SELECT ((? #> ?) - ?)\nFROM \"Json\"\n" "SELECT ((? #> ?) - ?)\nFROM \"Json\"\n"