Skip to content

Commit 5e49dea

Browse files
committed
wip! Introduce HK ClientRequest
Introduces ErrorState Introduces ApiModel
1 parent 61ca47f commit 5e49dea

5 files changed

Lines changed: 435 additions & 63 deletions

File tree

cabal.project

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,11 @@ packages:
99
webapi-openapi
1010
webapi-reflex-dom
1111
webapi-test
12+
13+
source-repository-package
14+
type: git
15+
location: https://github.com/byteally/rec
16+
tag: 13b29ebfcf6f2a2230734ee6eee2f653bcf75594
17+
subdir: rec
18+
19+
allow-newer: typerep-map:base, typerep-map:ghc-prim
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Test.WebApi.DynamicLogic
22
( successCall
3+
, successCallWith
34
, errorCall
45
, someExceptionCall
56
, propDL
@@ -22,22 +23,29 @@ import Test.QuickCheck.Monadic
2223
import Test.QuickCheck.Monadic qualified as QC
2324
import Test.QuickCheck.Extras
2425

25-
26+
2627
successCall :: forall meth r app apps. WebApiActionCxt apps meth app r =>
27-
ClientRequest meth (app :// r)
28+
ClientRequestF Input meth (app :// r)
2829
-> DL (ApiState apps) (Var (ApiOut meth (app :// r)))
29-
successCall creq = action (mkWebApiAction (SuccessCall creq))
30+
successCall creq = action (mkWebApiAction (SuccessCall creq defSuccessApiModel NoCookiesMod (Right . getSuccessOut)))
31+
32+
successCallWith :: forall meth r app res apps. (Typeable res, WebApiActionCxt apps meth app r) =>
33+
ClientRequestF Input meth (app :// r)
34+
-> ModifyClientCookies
35+
-> (ApiSuccess meth (app :// r) -> Either ResultError res)
36+
-> DL (ApiState apps) (Var res)
37+
successCallWith creq cookMod f = action (mkWebApiAction (SuccessCall creq defSuccessApiModel cookMod f))
3038

3139
errorCall :: forall meth r app apps.WebApiActionCxt apps meth app r =>
3240
ClientRequest meth (app :// r)
33-
-> DL (ApiState apps) (Var (ApiErr meth (app :// r)))
34-
errorCall creq = action (mkWebApiAction (ErrorCall creq))
41+
-> DL (ApiState apps) (Val (ApiErr meth (app :// r)))
42+
errorCall creq = action (mkWebApiAction (ErrorCall creq)) >>= (pure . Var id)
3543

3644
someExceptionCall :: forall meth r app apps. WebApiActionCxt apps meth app r =>
3745
ClientRequest meth (app :// r)
3846
-> DL (ApiState apps) (Var SomeException)
3947
someExceptionCall creq = action (mkWebApiAction (SomeExceptionCall creq))
40-
48+
4149
propDL :: (forall a. WebApiSessions apps a -> IO a) -> DL (ApiState apps) () -> Property
4250
propDL webapiRunner d = forAllDL d (prop_api webapiRunner)
4351

@@ -47,16 +55,3 @@ prop_api webapiRunner s =
4755
monitor $ counterexample "\nExecution\n"
4856
_ <- runActions s
4957
QC.assert True
50-
51-
{-
52-
prop_api :: forall apps. WebApiSessionsConfig apps -> Actions (ApiState apps) -> Property
53-
prop_api _ s =
54-
monadicIO $ do
55-
monitor $ counterexample "\nExecution\n"
56-
_ <- runPropertyStateT (runPropertyReaderT (hoistPropM (runWebApiSessions @apps) WebApiSessions $ runActions s) undefined) undefined
57-
QC.assert True
58-
59-
60-
hoistPropM :: (forall x. m x -> n x) -> (forall x. n x -> m x) -> PropertyM m a -> PropertyM n a
61-
hoistPropM fw bw p = MkPropertyM $ \hf -> fmap fw $ unPropertyM p ((fmap . fmap) bw hf)
62-
-}

0 commit comments

Comments
 (0)