Commit 8f9809b2 authored by MrMan's avatar MrMan

Start setting up tests

parent 72f2f666
......@@ -70,3 +70,14 @@ tests:
dependencies:
- haskell-restish-todo
- hspec
int:
main: Spec.hs
source-dirs: test/Integration
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- haskell-restish-todo
- hspec
......@@ -4,7 +4,9 @@
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE LambdaCase #-}
module Components.TaskStore.SQLite where
module Components.TaskStore.SQLite
(SQLiteTaskStore)
where
import Components.TaskStore.Migrations.SQLite (migrations)
import Config (CompleteTaskStoreConfig)
......
......@@ -202,6 +202,18 @@ buildConfigWithDefault orig partials = orig `absorbPartial` combinedPartials
combinedPartials :: PartialAppConfig
combinedPartials = Prelude.foldl (<>) (mempty :: PartialAppConfig) partials
-- | The default configuration *is* a fully specified complete app config @ mempty state
appConfigDefault :: CompleteAppConfig
appConfigDefault = mempty
-- | The default configuration *is* a fully specified complete app config @ mempty state
defaultCompleteAppConfig :: CompleteAppConfig
defaultCompleteAppConfig = mempty
-- | The default partially specified configuration is mempty
defaultPartialAppConfig :: PartialAppConfig
defaultPartialAppConfig = mempty
-- | Build an App configuration from a given file, using system environment as well as
makeAppConfig :: Maybe Prelude.FilePath -> ProcessEnvironment -> IO (Either ConfigurationError CompleteAppConfig)
makeAppConfig maybeStrPath env = try generateConfig
......@@ -227,12 +239,8 @@ makeAppConfig maybeStrPath env = try generateConfig
envCfg :: PartialAppConfig
envCfg = fromENV env :: PartialAppConfig
-- | The default configuration *is* a fully specified complete app config @ mempty state
defaultCfg :: CompleteAppConfig
defaultCfg = mempty
buildFromEnv :: IO CompleteAppConfig
buildFromEnv = pure $ absorbPartial defaultCfg envCfg
buildFromEnv = pure $ absorbPartial defaultCompleteAppConfig envCfg
getFileConfig :: FPCOS.FilePath -> IO (Either ConfigurationError PartialAppConfig)
getFileConfig = if isJSONFile then fromJSONFile else fromTOMLFile
......
module Components.TaskStore.SQLiteSpec (spec) where
import Components.TaskStore.SQLite
import Test.Hspec
main :: IO ()
main = hspec spec
spec :: Spec
spec = do
describe "defaults" $ do
it "works" $
True `shouldBe` True
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
......@@ -7,12 +7,6 @@ import Data.Functor.Identity
main :: IO ()
main = hspec spec
completeAppDefault :: CompleteAppConfig
completeAppDefault = C.defaultValue
partialAppDefault :: PartialAppConfig
partialAppDefault = C.defaultValue
spec :: Spec
spec = do
describe "defaults" $ do
......@@ -24,6 +18,11 @@ spec = do
describe "default values" $ do
it "CompleteAppConfig has default host" $
host completeAppDefault `shouldBe` Identity C.defaultHost
host C.defaultCompleteAppConfig `shouldBe` Identity C.defaultHost
it "CompleteAppConfig has default port" $
port completeAppDefault `shouldBe` Identity C.defaultPort
port C.defaultCompleteAppConfig `shouldBe` Identity C.defaultPort
it "PartialAppConfig has no default host" $
host C.defaultPartialAppConfig `shouldBe` Nothing
it "PartialAppconfig has no default port" $
port C.defaultPartialAppConfig `shouldBe` Nothing
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment