mongodb/test/TestImport.hs

38 lines
1.1 KiB
Haskell
Raw Permalink Normal View History

2015-03-18 10:35:51 +00:00
{-# LANGUAGE CPP #-}
2014-08-07 15:54:38 +00:00
module TestImport (
2015-03-18 10:35:51 +00:00
module TestImport,
2014-08-07 15:54:38 +00:00
module Export
) where
import Test.Hspec as Export hiding (Selector)
import Database.MongoDB as Export
import Control.Monad.Trans as Export (MonadIO, liftIO)
2015-03-18 10:35:51 +00:00
import Data.Time (ParseTime, UTCTime)
import qualified Data.Time as Time
-- We support the old version of time because it's easier than trying to use
-- only the new version and test older GHC versions.
#if MIN_VERSION_time(1,5,0)
import Data.Time.Format (defaultTimeLocale, iso8601DateFormat)
#else
import System.Locale (defaultTimeLocale, iso8601DateFormat)
2017-04-09 18:58:07 +00:00
import Data.Maybe (fromJust)
2015-03-18 10:35:51 +00:00
#endif
parseTime :: ParseTime t => String -> String -> t
#if MIN_VERSION_time(1,5,0)
parseTime = Time.parseTimeOrError True defaultTimeLocale
#else
parseTime fmt = fromJust . Time.parseTime defaultTimeLocale fmt
#endif
parseDate :: String -> UTCTime
parseDate = parseTime (iso8601DateFormat Nothing)
parseDateTime :: String -> UTCTime
parseDateTime = parseTime (iso8601DateFormat (Just "%H:%M:%S"))
mongodbHostEnvVariable :: String
mongodbHostEnvVariable = "HASKELL_MONGODB_TEST_HOST"