Skip to content

Issues when testing #87

@lucianolorenti

Description

@lucianolorenti

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions