git.iko.soy/rowtype-yoga/purs-eval
on main help sign in
test: fix validateReq
commit4776dff3455c2b3c5cec4c0539c44084fcd6fe6f authorWalker <walker@praiseweb.com.br> dateSat 29 Oct 2022, 19:51 (4 years ago) parent4fc3826
3 files changed+6−7
flake.nix+1 src/Main.purs+1−1 test/Main.purs+4−6
flake.nix+1
@@ -30,6 +30,7 @@
3030 with purs-nix.ps-pkgs;
3131 [
3232 prelude
33+ debug
3334 aff
3435 effect
3536 node-process
src/Main.purs+1−1
@@ -15,7 +15,7 @@ import Affjax.RequestBody (RequestBody (String))
1515
1616compile :: String -> Aff String
1717compile s = do
18− mRes <- post string "http://localhost:3000/compiler" $ Just $ String s
18+ mRes <- post string "http://localhost:3000/compile" $ Just $ String s
1919 res <- liftEither $ (error <<< printError) `lmap` mRes
2020 pure res.body
2121
test/Main.purs+4−6
@@ -1,7 +1,6 @@
11module Test.Main where
22
3−import Prelude (Unit, ($), (==), mempty, unit, pure, bind, const)
4−import Control.Bind ((>=>))
3+import Prelude (Unit, ($), (==), unit, pure, bind, const)
54import Control.Apply ((*>))
65import Control.Monad.Error.Class (class MonadThrow, throwError, liftMaybe)
76import Effect
@@ -12,7 +11,6 @@ import HTTPure.Request (Request)
1211import HTTPure.Response (ok)
1312import HTTPure.Server (serve)
1413import HTTPure.Body (class Body)
15−import HTTPure.Path (read)
1614import HTTPure.Lookup ((!!))
1715import Test.Unit (suite, test)
1816import Test.Unit.Main (runTest)
@@ -23,8 +21,8 @@ validateReq :: forall m. MonadThrow Error m => Request -> m Unit
2321validateReq req = do
2422 let invalidPath = error "invalid path"
2523 missingPath = error "missing path"
26− p <- liftMaybe missingPath $ read req !! 0
27− case p == "/compile" of
24+ p <- liftMaybe missingPath $ req.path !! 0
25+ case p == "compile" of
2826 true -> pure unit
2927 false -> throwError invalidPath
3028
@@ -42,4 +40,4 @@ main = runTest do
4240 test "produces expected output" do
4341 let expected = "2"
4442 actual <- setupSrv expected (compile "1+1")
45− actual `equal` expected
43+ expected `equal` actual