summaryrefslogtreecommitdiff
path: root/lambda-calcul/haskell/test/Minilang/ServerSpec.hs
diff options
context:
space:
mode:
authorArnaud Bailly <arnaud@pankzsoft.com>2026-04-01 16:18:01 +0200
committerArnaud Bailly <arnaud@pankzsoft.com>2026-04-01 16:22:02 +0200
commitf6dde1041a52da4f2e7ccb77eed3c577f9d07798 (patch)
treeee99b8a606b7dcb378744f62245209a7d4d8eda4 /lambda-calcul/haskell/test/Minilang/ServerSpec.hs
parentd820a635afb69c44f736e941bbe094ad6a838073 (diff)
downloadlambda-nantes-f6dde1041a52da4f2e7ccb77eed3c577f9d07798.tar.gz
Remove answers from sent challenges
Also fix integration test
Diffstat (limited to 'lambda-calcul/haskell/test/Minilang/ServerSpec.hs')
-rw-r--r--lambda-calcul/haskell/test/Minilang/ServerSpec.hs12
1 files changed, 6 insertions, 6 deletions
diff --git a/lambda-calcul/haskell/test/Minilang/ServerSpec.hs b/lambda-calcul/haskell/test/Minilang/ServerSpec.hs
index 2860c40..8d0b182 100644
--- a/lambda-calcul/haskell/test/Minilang/ServerSpec.hs
+++ b/lambda-calcul/haskell/test/Minilang/ServerSpec.hs
@@ -51,7 +51,7 @@ spec = with (app testSeed) $ do
it "GET /api/leaderboard returns empty list of scores at start" $ do
get "/api/leaderboard"
- `shouldRespondWith` 200 {matchBody = arrayOfLengthOf (Proxy @Score) 0}
+ `shouldRespondWith` 200{matchBody = arrayOfLengthOf (Proxy @Score) 0}
it "POST /api/register returns registration token given user is not registered" $ do
postJSON "/api/register" alice
@@ -66,7 +66,7 @@ spec = with (app testSeed) $ do
it "GET /api/leaderboard returns list of one element after user registers" $ do
void $ postJSON "/api/register" alice
get "/api/leaderboard"
- `shouldRespondWith` 200 {matchBody = arrayOfLengthOf (Proxy @Score) 1}
+ `shouldRespondWith` 200{matchBody = arrayOfLengthOf (Proxy @Score) 1}
it "POST /api/register returns 400 given user is already registered" $ do
void $ postJSON "/api/register" alice
@@ -84,7 +84,7 @@ spec = with (app testSeed) $ do
`shouldRespondWith` 404
it "GET /api/challenge returns next challenge given user is registered" $ do
- let expected = LT.unpack $ decodeUtf8 $ encode $ Challenge {level = 0, expr = "x", description = "A lone free variable. What does x reduce to?", answer = "x"}
+ let expected = LT.unpack $ decodeUtf8 $ encode $ Challenge{level = 0, expr = "x", description = "A lone free variable. What does x reduce to?"}
postJSON "/api/register" alice
`shouldRespondWith` 201
@@ -123,7 +123,7 @@ spec = with (app testSeed) $ do
`shouldRespondWith` 400
it "GET /api/challenge returns next level challenge after successful POST" $ do
- let expected = LT.unpack $ decodeUtf8 $ encode $ Challenge {level = 1, expr = "y", description = "Another free variable. What does y reduce to?", answer = "y"}
+ let expected = LT.unpack $ decodeUtf8 $ encode $ Challenge{level = 1, expr = "y", description = "Another free variable. What does y reduce to?"}
void $ postJSON "/api/register" alice
void $ postJSON ("/api/challenge?token=" <> LBS.toStrict token) "\"x\""
@@ -147,7 +147,7 @@ spec = with (app testSeed) $ do
{ matchBody = MatchBody $ \_ actual ->
case eitherDecode actual of
Right (score :: Score) ->
- if score == Score {user = User "alice", grade = 0, lastTest = Nothing, lastResult = Nothing}
+ if score == Score{user = User "alice", grade = 0, lastTest = Nothing, lastResult = Nothing}
then Nothing
else Just $ "Expected score with grade 0, but got " ++ show score
Left err -> Just $ "Failed to decode JSON: " ++ err
@@ -190,7 +190,7 @@ spec = with (app testSeed) $ do
postJSON :: BS.ByteString -> ByteString -> WaiSession () SResponse
postJSON url = request "POST" url [("Content-Type", "application/json")]
-arrayOfLengthOf :: forall elem proxy. (FromJSON elem) => proxy elem -> Int -> MatchBody
+arrayOfLengthOf :: forall elem proxy. FromJSON elem => proxy elem -> Int -> MatchBody
arrayOfLengthOf _ len = MatchBody $ \_ actual ->
case eitherDecode actual of
Right (scores :: [elem]) ->