2021-10-01 02:24:21 +02:00
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
{-# LANGUAGE ConstraintKinds #-}
|
|
|
|
{-# LANGUAGE DataKinds #-}
|
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
|
|
{-# LANGUAGE FlexibleInstances #-}
|
|
|
|
{-# LANGUAGE GADTs #-}
|
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
{-# LANGUAGE PolyKinds #-}
|
|
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
|
|
|
{-# LANGUAGE TypeFamilies #-}
|
|
|
|
{-# LANGUAGE TypeOperators #-}
|
|
|
|
{-# LANGUAGE UndecidableInstances #-}
|
|
|
|
{-# OPTIONS_GHC -freduction-depth=100 #-}
|
|
|
|
{-# OPTIONS_GHC -fno-warn-orphans #-}
|
|
|
|
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
|
|
|
|
|
|
|
|
module Servant.GenericSpec (spec) where
|
|
|
|
|
|
|
|
import Test.Hspec
|
|
|
|
|
2021-10-08 15:45:18 +02:00
|
|
|
import Servant.Client ((//), (/:))
|
2021-10-01 02:24:21 +02:00
|
|
|
import Servant.ClientTestUtils
|
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = describe "Servant.GenericSpec" $ do
|
|
|
|
genericSpec
|
|
|
|
|
|
|
|
genericSpec :: Spec
|
|
|
|
genericSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
|
|
|
|
context "Record clients work as expected" $ do
|
|
|
|
|
|
|
|
it "Client functions return expected values" $ \(_,baseUrl) -> do
|
2021-10-08 15:45:18 +02:00
|
|
|
runClient (recordRoutes // version) baseUrl `shouldReturn` Right 42
|
|
|
|
runClient (recordRoutes // echo /: "foo") baseUrl `shouldReturn` Right "foo"
|
2021-10-01 02:24:21 +02:00
|
|
|
it "Clients can be nested" $ \(_,baseUrl) -> do
|
2021-10-08 15:45:18 +02:00
|
|
|
runClient (recordRoutes // otherRoutes /: 42 // something) baseUrl `shouldReturn` Right ["foo", "bar", "pweet"]
|