mirror of
https://github.com/haskell-servant/servant-ekg.git
synced 2024-11-23 03:29:43 +01:00
More tests
This commit is contained in:
parent
787bfb5c1b
commit
c48a9aa851
2 changed files with 15 additions and 10 deletions
|
@ -10,7 +10,7 @@
|
|||
# resolver:
|
||||
# name: custom-snapshot
|
||||
# location: "./custom-snapshot.yaml"
|
||||
resolver: lts-5.16
|
||||
resolver: lts-7.18
|
||||
|
||||
# User packages to be built.
|
||||
# Various formats can be used as shown in the example below.
|
||||
|
@ -35,11 +35,6 @@ packages:
|
|||
# Dependency packages to be pulled from upstream that are not in the resolver
|
||||
# (e.g., acme-missiles-0.3)
|
||||
extra-deps:
|
||||
- servant-0.7.1
|
||||
- servant-server-0.7.1
|
||||
- servant-client-0.7.1
|
||||
- warp-3.2.6
|
||||
- http2-1.6.0
|
||||
|
||||
# Override default flag values for local packages and extra-deps
|
||||
flags: {}
|
||||
|
|
|
@ -18,7 +18,7 @@ import Data.Proxy
|
|||
import qualified Data.HashMap.Strict as H
|
||||
import Data.Text
|
||||
import GHC.Generics
|
||||
import Network.HTTP.Client (defaultManagerSettings, newManager)
|
||||
import Network.HTTP.Client (defaultManagerSettings, newManager, Manager)
|
||||
import Network.Wai
|
||||
import Network.Wai.Handler.Warp
|
||||
import Servant
|
||||
|
@ -36,20 +36,30 @@ import Servant.Ekg
|
|||
spec :: Spec
|
||||
spec = describe "servant-ekg" $ do
|
||||
|
||||
let getEp :<|> _postEp :<|> _deleteEp = client testApi
|
||||
let getEp :<|> postEp :<|> deleteEp = client testApi
|
||||
|
||||
it "collects number of request" $ do
|
||||
withApp $ \port mvar -> do
|
||||
mgr <- newManager defaultManagerSettings
|
||||
let runFn :: (Manager -> BaseUrl -> ExceptT e m a) -> m (Either e a)
|
||||
#if MIN_VERSION_servant(0,9,0)
|
||||
Right _result <- runClientM (getEp "name" Nothing) (ClientEnv mgr (BaseUrl Http "localhost" port ""))
|
||||
runFn fn = runClientM $ fn mgr (ClientEnv mgr (BaseUrl Http "localhost" port ""))
|
||||
#else
|
||||
_result <- runExceptT $ getEp "name" Nothing mgr (BaseUrl Http "localhost" port "")
|
||||
runFn fn = runExceptT $ fn mgr (BaseUrl Http "localhost" port "")
|
||||
#endif
|
||||
_ <- runFn $ getEp "name" Nothing
|
||||
_ <- runFn $ postEp (Greet "hi")
|
||||
_ <- runFn $ deleteEp "blah"
|
||||
m <- readMVar mvar
|
||||
case H.lookup "hello.:name.GET" m of
|
||||
Nothing -> fail "Expected some value"
|
||||
Just v -> Counter.read (metersC2XX v) `shouldReturn` 1
|
||||
case H.lookup "greet.POST" m of
|
||||
Nothing -> fail "Expected some value"
|
||||
Just v -> Counter.read (metersC2XX v) `shouldReturn` 1
|
||||
case H.lookup "greet.:greetid.DELETE" m of
|
||||
Nothing -> fail "Expected some value"
|
||||
Just v -> Counter.read (metersC2XX v) `shouldReturn` 1
|
||||
|
||||
it "is comprehensive" $ do
|
||||
let _typeLevelTest = monitorEndpoints comprehensiveAPI undefined undefined undefined
|
||||
|
|
Loading…
Reference in a new issue