Skip to content

Commit

Permalink
[#500] Start some basic work on trails service.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-stacey committed Jul 16, 2019
1 parent 5383faf commit 495c717
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 16 deletions.
4 changes: 2 additions & 2 deletions projects/trails/app/Trails.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Main where

import Lib
import qualified Mirza.Trails.Main as T (main)

main :: IO ()
main = someFunc
main = T.main
6 changes: 0 additions & 6 deletions projects/trails/src/Lib.hs

This file was deleted.

1 change: 1 addition & 0 deletions projects/trails/src/Mirza/Trails/Client/Servant.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Mirza.Trails.Client.Servant where
6 changes: 6 additions & 0 deletions projects/trails/src/Mirza/Trails/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Mirza.Trails.Main where
main :: IO ()
main = putStrLn "Trails..."

someFunc :: IO ()
someFunc = putStrLn "someFunc"
4 changes: 3 additions & 1 deletion projects/trails/stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ resolver: lts-13.28
# - wai
packages:
- .
- '../mirza-common-haskell'
- '../mirza-test-utils-haskell'
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
Expand Down Expand Up @@ -76,6 +78,6 @@ extra-deps:


ghc-options:
$locals: -Wall
$locals: -Wall -Werror

local-bin-path: dist
19 changes: 19 additions & 0 deletions projects/trails/test/Mirza/Trails/Spec.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Main where

import Mirza.Trails.Tests.Client

import Test.Tasty hiding (withResource)
import Test.Tasty.Runners (NumThreads (..))

import Control.Exception (bracket)
import Control.Monad.Except (liftIO, runExceptT)

main :: IO ()
main = do
either (error . show) pure =<< (liftIO $ runExceptT $ makeDatabase testDbNameTrails)

clientTests <- clientSpec

defaultMain $ localOption (NumThreads 1) $ testGroup "tests"
[ clientTests
]
37 changes: 37 additions & 0 deletions projects/trails/test/Mirza/Trails/Tests/Client.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Mirza.Trails.Tests.Client where


import Mirza.Trails.Client.Servant

import Mirza.Trails.Tests.InitClient

import Mirza.Common.Tests.ServantUtils

import Test.Hspec.Expectations
import Test.Tasty
import Test.Tasty.HUnit

import Control.Exception (bracket)


-- === OR Servant Client tests
clientSpec :: IO TestTree
clientSpec = do




let healthTests = testCaseSteps "Provides health status" $ \step ->
bracket runTrailsApp (\(a,b,_) -> endWaiApp (a,b)) $ \(_tid, baseurl) -> do
let http = runClient baseurl

step "Status results in 200"
-- healthResult <- http health
-- healthResult `shouldSatisfy` isRight
-- healthResult `shouldBe` (Right HealthResponse)


pure $ testGroup "Trails HTTP Client tests"
[
healthTests
]
2 changes: 0 additions & 2 deletions projects/trails/test/Spec.hs

This file was deleted.

24 changes: 19 additions & 5 deletions projects/trails/trails.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,50 @@ source-repository head

library
exposed-modules:
Lib
Mirza.Trails.Main
Mirza.Trails.Client.Servant
other-modules:
Paths_trails
hs-source-dirs:
src
build-depends:
base >=4.7 && <5
, mirza-test-utils-haskell
default-language: Haskell2010

executable trails-exe
main-is: Main.hs
executable trails
main-is: Trails.hs
other-modules:
Paths_trails
hs-source-dirs:
app
ghc-options: -threaded -rtsopts -with-rtsopts=-N
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Werror
build-depends:
base >=4.7 && <5
, trails
default-language: Haskell2010

test-suite trails-test
type: exitcode-stdio-1.0
main-is: Spec.hs
main-is: Mirza/Trails/Spec.hs
other-modules:
Paths_trails
, Mirza.Trails.Tests.Client
, Mirza.Trails.Tests.InitClient
hs-source-dirs:
test
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -Werror
build-depends:
base >=4.7 && <5
, trails
, mirza-common-haskell
, mirza-test-utils-haskell
, hspec-expectations
, mtl
, tasty
, tasty-hunit
default-language: Haskell2010

source-repository head
type: git
location: https://github.com/data61/Mirza

0 comments on commit 495c717

Please sign in to comment.