diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index f5d0ecb..1277206 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -23,7 +23,7 @@ jobs: MYSQL_DATABASE: esqutest ## map the "external" 33306 port with the "internal" 3306 ports: - - 3306:3306 + - 33306:3306 # Set health checks to wait until mysql database has started (it takes some seconds to start) options: >- --health-cmd="mysqladmin ping" diff --git a/test/MySQL/Test.hs b/test/MySQL/Test.hs index f5102d7..d74535b 100644 --- a/test/MySQL/Test.hs +++ b/test/MySQL/Test.hs @@ -237,12 +237,39 @@ migrateIt = do withConn :: RunDbMonad m => (SqlBackend -> R.ResourceT m a) -> m a -withConn = - R.runResourceT . - withMySQLConn defaultConnectInfo - { connectHost = "localhost" - , connectUser = "travis" - , connectPassword = "esqutest" - , connectDatabase = "esqutest" - , connectPort = 3306 - } +withConn f = do + ci <- isCI + let connInfo + | ci = + defaultConnectInfo + { connectHost = "localhost" + , connectUser = "travis" + , connectPassword = "esqutest" + , connectDatabase = "esqutest" + , connectPort = 33306 + } + | otherwise = + defaultConnectInfo + { connectHost = "localhost" + , connectUser = "travis" + , connectPassword = "esqutest" + , connectDatabase = "esqutest" + , connectPort = 3306 + } + R.runResourceT $ + withMySQLConn defaultConnectInfo + { connectHost = "localhost" + , connectUser = "travis" + , connectPassword = "esqutest" + , connectDatabase = "esqutest" + , connectPort = 3306 + } + f + +isCI :: IO Bool +isCI = do + env <- liftIO 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 985ac7b..58f6b09 100644 --- a/test/PostgreSQL/Test.hs +++ b/test/PostgreSQL/Test.hs @@ -898,7 +898,7 @@ testConcatenationOperator = testMinusOperator :: Spec testMinusOperator = - fdescribe "Minus Operator" $ do + describe "Minus Operator" $ do it "creates sane SQL" $ do let obj = object ["a" .= False, "b" .= True] encoded = BSL.toStrict $ encode obj @@ -919,21 +919,21 @@ testMinusOperator = , PersistInt64 0 ] it "works as expected" $ run $ do - x <- selectJSON $ \v -> do - where_ $ v @>. jsonbVal (toJSON ([] :: [Int])) - where_ $ v JSON.-. 0 @>. jsonbVal (toJSON [Bool True]) - y <- selectJSON $ \v -> do - where_ $ v @>. jsonbVal (toJSON ([] :: [Int])) - where_ $ v JSON.-. (-1) @>. jsonbVal (toJSON [Null]) - z <- selectJSON_ $ \v -> v JSON.-. "b" ?&. ["a", "b"] - w <- selectJSON_ $ \v -> do - v JSON.-. "test" @>. jsonbVal (toJSON [String "test"]) - liftIO $ length x `shouldBe` 2 - liftIO $ length y `shouldBe` 1 - liftIO $ length z `shouldBe` 0 - liftIO $ length w `shouldBe` 0 - sqlFailWith "22023" $ selectJSONwhere $ \v -> - v JSON.-. 0 @>. jsonbVal (toJSON ([] :: [Int])) + x <- selectJSON $ \v -> do + where_ $ v @>. jsonbVal (toJSON ([] :: [Int])) + where_ $ v JSON.-. 0 @>. jsonbVal (toJSON [Bool True]) + y <- selectJSON $ \v -> do + where_ $ v @>. jsonbVal (toJSON ([] :: [Int])) + where_ $ v JSON.-. (-1) @>. jsonbVal (toJSON [Null]) + z <- selectJSON_ $ \v -> v JSON.-. "b" ?&. ["a", "b"] + w <- selectJSON_ $ \v -> do + v JSON.-. "test" @>. jsonbVal (toJSON [String "test"]) + liftIO $ length x `shouldBe` 2 + liftIO $ length y `shouldBe` 1 + liftIO $ length z `shouldBe` 0 + liftIO $ length w `shouldBe` 0 + sqlFailWith "22023" $ selectJSONwhere $ \v -> + v JSON.-. 0 @>. jsonbVal (toJSON ([] :: [Int])) where selectJSON_ f = selectJSON $ \v -> do where_