leaf
Use child router in the test cases
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.
Popular in Questions
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
Hi all,
Trying to get some more clarity over utc_datetime and naive_datetime for Ecto:
https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set?
Thanks.
New
Student & New to elixir. Nice language.
I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
Hello,
I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these
buyer = %{
id: ...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this
"1000"
What is the ...
New
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project.
Baby step #1 is extracting the number ...
New
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Other popular topics
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Hello!
Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this:
...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
As a follow up to my earlier question:
I have the code compiling and running but not getting a successful login from the rest server. ...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Hello, I have map which I want to convert it to string like this:
the map:
%{last_name: "tavakkoli", name: "shahryar"}
the string I ne...
New
Hi all,
I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I'm trying to use Postg...
New








