forked from vijaygupta18/euler-hs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scenario1.hs
28 lines (24 loc) · 957 Bytes
/
Scenario1.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-# OPTIONS_GHC -fno-warn-deprecations -Werror #-}
module EulerHS.TestData.Scenarios.Scenario1
(
mkUrl, testScenario1
) where
import EulerHS.TestData.API.Client (User (User), getUser, port, userGUID)
import Data.Text (pack)
import EulerHS.Language
import EulerHS.Prelude hiding (getOption, pack)
import EulerHS.TestData.Types
import Servant.Client (BaseUrl (..), Scheme (..))
mkUrl :: String -> BaseUrl
mkUrl host = BaseUrl Http host port ""
testScenario1 :: Flow User
testScenario1 = do
localUserName <- pack <$> runSysCmd "whoami"
localGUID <- runIO (undefined :: IO Text)
guid <- generateGUID
url <- maybe (mkUrl "localhost") mkUrl <$> getOption UrlKey
res <- callServantAPI Nothing url getUser
case res of
Right u -> if localGUID /= userGUID u then pure u
else pure $ User localUserName "" guid
_ -> pure $ User localUserName "Smith" guid