wookay/Bukdu.jl

Issues when testing

lucianolorenti opened this issue · 0 comments

Hi! I am writing a few tests of my app and I facing an issue

using Bukdu
using Test
struct IndexController <: ApplicationController
    conn::Conn
end
function something(c::IndexController)
    data = c.conn.params[:data]
    return Bukdu.render(JSON,  Dict("status"=>data=="data"))
end
function config_routes()
    routes() do
        post("/something", IndexController, something)
    end
end
function test_something()
    config_routes()
    response = Bukdu.Router.call(post,
                            "/something",
                            ["Content-Type" => "application/json"],
                            JSON.json(Dict("data"=>"data")))
                            
    @test response.got["message"] = true
end
test_something()

And I got a INFO: POST MissingController not_found 404 /something

I solved using invokelatest

    response = Base.invokelatest(Bukdu.Router.call,
                            post,
                            "/something",
                            ["Content-Type" => "application/json"],
                            JSON.json(Dict("data"=>"data")))

Is this intended, should I be testing in a different way?