Skip to content

Commit

Permalink
Added unit test for deletef request (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
OnofreTZK authored Oct 21, 2022
1 parent b50fc42 commit dc999a9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/Saturn.UnitTests/RouterTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let testRouter = router {
post "/post/2" (text "2")
put "/user/123" (text "User updated!")
delete "/user/123" (text "User deleted!")
deletef "/user/%f" (fun (userId : float) -> (sprintf "The user deleted is: %.1f" userId) |> text)
}

[<Tests>]
Expand Down Expand Up @@ -97,6 +98,16 @@ let tests =
| None -> failtestf "Result was expected to be %s" expected
| Some ctx ->
Expect.equal (getBody ctx) expected "Result should be equal"

testCase "DELETEF to `/user/1.0` returns `The user deleted is: 1.0`" <| fun _ ->
let ctx = getEmptyContext "DELETE" "/user/1.0"

let expected = "The user deleted is: 1.0"
let result = testRouter next ctx |> runTask
match result with
| None -> failtestf "Result was expected to be %s" expected
| Some ctx ->
Expect.equal (getBody ctx) expected "Result should be equal"
]

let testCiRouter = router {
Expand Down

0 comments on commit dc999a9

Please sign in to comment.