ambiorix icon indicating copy to clipboard operation
ambiorix copied to clipboard

Feature Request: Testing of an API

Open DavZim opened this issue 4 months ago • 1 comments

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")
...

DavZim avatar Sep 19 '25 08:09 DavZim

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?

JohnCoene avatar Sep 25 '25 22:09 JohnCoene