ambiorix
ambiorix copied to clipboard
Feature Request: Testing of an API
It would be great if we can have methods and documentation how we can test an API class, including middlewares etc.
Eg the following mocked code would be great
app <- Ambiorix$new()
app$get("/", \(req, res) {
res$send("Hi")
})
# somehow create a request (maybe httr2 or similar)
r <- ambiorix::request("GET", "/")
res <- app$evaluate(r)
expect_equal(res$status, 200),
expect_equal(res$content |> as.character(), "Hi")
...
Yes, it's a good point. I never really looked into it, I'm not sure how we should handle this.
I'm not a fan of mocking but it may be necessary here @kennedymwavu, any thoughts?