I have two routers in my app. I am forwarding api calls which start with /admin_api/v1
to a child router from the main router.
forward "/admin_api/v1", Admin.ApiWeb.Router
It works fine when I test it with Postman. Both routers are working as expected. This is path in the child router.
qa_question_path DELETE /qa_questions/:nuton_id NutonAdminApi.QaQuestionController :delete
qa_question_path PUT /qa_questions/:nuton_id NutonAdminApi.QaQuestionController :update
This is route in the parent route for the same entity.
qa_question_path GET /api/v1/qa_questions NutonApi.QaQuestionController :index
qa_question_path POST /api/v1/qa_questions NutonApi.QaQuestionController :create
Their path names are the same but their EP are different.
When I run following test case
json_resp =
put(
conn,
qa_question_path(conn, :update, id),
params
)
|> json_response(200)
It gives me this error:
** (ArgumentError) no action :update for ApiWeb.Router.Helpers.qa_question_path/3. The following actions/clauses are supported:
qa_question_path(conn_or_endpoint, :create, params \\ [])
qa_question_path(conn_or_endpoint, :index, params \\ [])
qa_question_path(conn_or_endpoint, :show, nuton_id, params \\ [])
I understand the issue because of the same path names in both routes . It just checks if the path exist in the parent and raise an error, but how can I include child router in the test cases so that it will check if the path exist in it.