module Test.Services where
import API.Brig
import API.Common
import SetupHelpers
import Testlib.Prelude
testUpdateServiceUpdateAcceptHeader :: (HasCallStack) => App ()
= do
let dom :: Domain
dom = Domain
OwnDomain
String
email <- App String
randomEmail
Value
alice <- Domain -> CreateUser -> App Value
forall domain.
(HasCallStack, MakesValue domain) =>
domain -> CreateUser -> App Value
randomUser Domain
dom CreateUser
forall a. Default a => a
def
Value
provider <- Value -> NewProvider -> App Value
forall user.
(HasCallStack, MakesValue user) =>
user -> NewProvider -> App Value
setupProvider Value
alice NewProvider
forall a. Default a => a
def {newProviderEmail = email}
String
pId <- Value
provider Value -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"id" App Value -> (App Value -> App String) -> App String
forall a b. a -> (a -> b) -> b
& App Value -> App String
forall a. (HasCallStack, MakesValue a) => a -> App String
asString
Value
service <- Domain -> String -> NewService -> App Value
forall dom.
(HasCallStack, MakesValue dom) =>
dom -> String -> NewService -> App Value
newService Domain
dom String
pId NewService
forall a. Default a => a
def
Value
sId <- Value
service Value -> String -> App Value
forall a. (HasCallStack, MakesValue a) => a -> String -> App Value
%. String
"id"
App ByteString -> App ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
(App ByteString -> App ()) -> App ByteString -> App ()
forall a b. (a -> b) -> a -> b
$ Domain
-> String -> Value -> Maybe String -> Maybe String -> App Response
forall dom serviceId.
(HasCallStack, MakesValue dom, MakesValue serviceId) =>
dom
-> String
-> serviceId
-> Maybe String
-> Maybe String
-> App Response
updateService Domain
dom String
pId Value
sId (String -> Maybe String
forall a. a -> Maybe a
Just String
"application/json") (String -> Maybe String
forall a. a -> Maybe a
Just String
"brand new service")
App Response -> (Response -> App ByteString) -> App ByteString
forall a b. App a -> (a -> App b) -> App b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= HasCallStack => Int -> Response -> App ByteString
Int -> Response -> App ByteString
getBody Int
200
App ByteString -> App ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
(App ByteString -> App ()) -> App ByteString -> App ()
forall a b. (a -> b) -> a -> b
$ Domain
-> String -> Value -> Maybe String -> Maybe String -> App Response
forall dom serviceId.
(HasCallStack, MakesValue dom, MakesValue serviceId) =>
dom
-> String
-> serviceId
-> Maybe String
-> Maybe String
-> App Response
updateService Domain
dom String
pId Value
sId (String -> Maybe String
forall a. a -> Maybe a
Just String
"text/plain") (String -> Maybe String
forall a. a -> Maybe a
Just String
"even newer service")
App Response -> (Response -> App ByteString) -> App ByteString
forall a b. App a -> (a -> App b) -> App b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= HasCallStack => Int -> Response -> App ByteString
Int -> Response -> App ByteString
getBody Int
200
App ByteString -> App ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
(App ByteString -> App ()) -> App ByteString -> App ()
forall a b. (a -> b) -> a -> b
$ Domain
-> String -> Value -> Maybe String -> Maybe String -> App Response
forall dom serviceId.
(HasCallStack, MakesValue dom, MakesValue serviceId) =>
dom
-> String
-> serviceId
-> Maybe String
-> Maybe String
-> App Response
updateService Domain
dom String
pId Value
sId Maybe String
forall a. Maybe a
Nothing (String -> Maybe String
forall a. a -> Maybe a
Just String
"really old service")
App Response -> (Response -> App ByteString) -> App ByteString
forall a b. App a -> (a -> App b) -> App b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= HasCallStack => Int -> Response -> App ByteString
Int -> Response -> App ByteString
getBody Int
200