Skip to content

Commit 00aba5b

Browse files
committed
Add test for retry combinator
1 parent 6ef0037 commit 00aba5b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/Main.purs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,19 @@ assertEq x y = if x == y
5151
then return unit
5252
else assertFail $ "Expected " <> show x <> ", got " <> show y
5353

54-
-- | For helping type inference
54+
-- | For helping type inference
5555
typeIs :: forall e a. a -> Assert e Unit
5656
typeIs = const (return unit)
5757

5858
main = runAff throwException (const $ log "affjax: All good!") $ do
5959
let ok200 = StatusCode 200
6060
let notFound404 = StatusCode 404
6161

62+
A.log "GET /does-not-exists: should be 404 Not found after retries"
63+
(attempt $ retry (Just 5000) affjax $ defaultRequest { url = "/does-not-exist" }) >>= assertRight >>= \res -> do
64+
typeIs (res :: AffjaxResponse String)
65+
assertEq notFound404 res.status
66+
6267
A.log "GET /mirror: should be 200 OK"
6368
(attempt $ affjax $ defaultRequest { url = "/mirror" }) >>= assertRight >>= \res -> do
6469
typeIs (res :: AffjaxResponse Foreign)

0 commit comments

Comments
 (0)