Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With clause in the controller gets missing coverage, works when has some calculation before #272

Open
anantanant2015 opened this issue Dec 6, 2021 · 1 comment

Comments

@anantanant2015
Copy link

anantanant2015 commented Dec 6, 2021

For example if working on the user update:

def update(conn, params) do
  with {:ok, user} <- User.update(params) do
    render(conn, "user.json", user: user)
  end
end

Here with {:ok, user} <- User.update(params) do this line is left uncovered.

If we wish to cover this, or the cases where these type of blocks gets covered:

def update(conn, params) do
   user = conn.assigns.user

  updated_params =
    params
    |> Map.put("store_uuid", user.store_uuid)
    |> Map.put("created_by", user.user_uuid)

   with {:ok, user} <- User.update(params) do
    render(conn, "user.json", user: user)
  end
end
@parroty
Copy link
Owner

parroty commented Dec 8, 2021

Hi. Thank you for the comment. I'm afraid that certain lines (statements) can be taken as uncovered. The following might be related.

I'm not sure if it matches your expectation, but one option could be to ignore certain lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants