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

Tests FAILED: Expected minimum coverage of 100%, got 99.5% #230

Closed
nelsonic opened this issue Oct 17, 2022 · 5 comments
Closed

Tests FAILED: Expected minimum coverage of 100%, got 99.5% #230

nelsonic opened this issue Oct 17, 2022 · 5 comments
Assignees
Labels
chore a tedious but necessary task often paying technical debt help wanted If you can help make progress with this issue, please comment! tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies

Comments

@nelsonic
Copy link
Member

Just ran:

mix c

On main branch on localhost and got the following output:

Finished in 16.8 seconds (16.8s async, 0.00s sync)
1 property, 150 tests, 0 failures

Randomized with seed 334479
----------------
COV    FILE                                        LINES RELEVANT   MISSED
100.0% lib/auth.ex                                     9        0        0
100.0% lib/auth/apikey.ex                            105       15        0
100.0% lib/auth/app.ex                               158       17        0
100.0% lib/auth/email.ex                              41        7        0
100.0% lib/auth/init/init.ex                         124       26        0
100.0% lib/auth/init/roles.ex                         69        3        0
100.0% lib/auth/init/statuses.ex                     113        3        0
 96.6% lib/auth/log.ex                               137       29        1
100.0% lib/auth/people_roles.ex                      136       12        0
100.0% lib/auth/permission.ex                        120        8        0
 98.3% lib/auth/person.ex                            371       58        1
100.0% lib/auth/repo.ex                                5        0        0
100.0% lib/auth/role.ex                              212       30        0
100.0% lib/auth/session.ex                           105       16        0
100.0% lib/auth/status.ex                             46        8        0
100.0% lib/auth/user_agent.ex                        101       25        0
100.0% lib/auth_web/controllers/api_controller.       70       19        0
100.0% lib/auth_web/controllers/app_controller.      111       36        0
 99.3% lib/auth_web/controllers/auth_controller      507      141        1
100.0% lib/auth_web/controllers/init_controller       45        7        0
100.0% lib/auth_web/controllers/people_controll       34        8        0
100.0% lib/auth_web/controllers/permission_cont       61       19        0
100.0% lib/auth_web/controllers/ping_controller        8        1        0
100.0% lib/auth_web/controllers/role_controller      192       67        0
100.0% lib/auth_web/endpoint.ex                       54        0        0
100.0% lib/auth_web/gettext.ex                        24        0        0
100.0% lib/auth_web/plugs/is_owner.ex                 12        1        0
100.0% lib/auth_web/router.ex                        103       25        0
100.0% lib/auth_web/views/app_view.ex                  3        0        0
100.0% lib/auth_web/views/auth_view.ex                 3        0        0
100.0% lib/auth_web/views/error_view.ex               30        4        0
100.0% lib/auth_web/views/init_view.ex                 3        0        0
100.0% lib/auth_web/views/layout_view.ex               3        0        0
100.0% lib/auth_web/views/people_view.ex              35        7        0
100.0% lib/auth_web/views/permission_view.ex           3        0        0
100.0% lib/auth_web/views/role_view.ex                10        3        0
[TOTAL]  99.5%
----------------

FAILED: Expected minimum coverage of 100%, got 99.5%.

I've made most of the recent changes to this repo ... https://github.com/dwyl/auth/commits/main 🧑‍💻
So going investigate this now. 🔍

@nelsonic nelsonic added help wanted If you can help make progress with this issue, please comment! chore a tedious but necessary task often paying technical debt technical A technical issue that requires understanding of the code, infrastructure or dependencies tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written labels Oct 17, 2022
@nelsonic nelsonic self-assigned this Oct 17, 2022
@nelsonic nelsonic added this to More ToDo ThanCanEver Be Done in Nelson's List via automation Oct 17, 2022
@nelsonic
Copy link
Member Author

Going through the test coverage report in the browser we can see that /auth/cover/excoveralls.html#lib/auth/log.ex has an uncovered guard function:

image

Which caused me to ask the question:

Why are we defining a utility function stringify/1 inside the Auth.Log module...? 🤷‍♂️

I'm sure this made sense to 2-years ago Nelson ... 🙄 ⏳
https://github.com/dwyl/auth/blame/f6a72102fd72f99ba8c42d00083e22c2fdec917a/lib/auth/log.ex#L134
But this feels like it belongs in our Useful utility library instead
so that it can be independently tested, documented and re-used in other projects! ♻️

Side-quest: dwyl/useful#11 ⚔️ #brb

@nelsonic nelsonic moved this from More ToDo ThanCanEver Be Done to In progress in Nelson's List Oct 17, 2022
@nelsonic
Copy link
Member Author

Created PR: dwyl/useful#26

Next in lib/auth/person.ex there is one line that isn't covered:

image

Can't that I know how I'm going to test this ... 💭

@nelsonic
Copy link
Member Author

Added test:

  test "Auth.Person.decrypt_email/1" do
    email = "alex@gmail.com"
    encrypted = email |> Fields.AES.encrypt() |> Base58.encode()
    decrypted = Person.decrypt_email(encrypted)
    assert email == decrypted

    # Unhappy ("rescue") path:
    invalid_email = ""
    assert Person.decrypt_email(invalid_email) == 0
  end

Last one in lib/auth_web/auth_controller.ex ...

image

defp client_id_is_current? ... yay trying to test a private function! 🎉 (🙄 ...)

@nelsonic
Copy link
Member Author

No idea why/how these lines were not being reported as uncovered by tests in previous builds ... 🤷‍♂️
But they are now all covered. ✅

@nelsonic
Copy link
Member Author

Finished in 16.9 seconds (16.9s async, 0.00s sync)
1 property, 152 tests, 0 failures

Randomized with seed 231724
----------------
COV    FILE                                        LINES RELEVANT   MISSED
100.0% lib/auth.ex                                     9        0        0
100.0% lib/auth/apikey.ex                            105       15        0
100.0% lib/auth/app.ex                               158       17        0
100.0% lib/auth/email.ex                              41        7        0
100.0% lib/auth/init/init.ex                         124       26        0
100.0% lib/auth/init/roles.ex                         69        3        0
100.0% lib/auth/init/statuses.ex                     113        3        0
100.0% lib/auth/log.ex                               125       25        0
100.0% lib/auth/people_roles.ex                      136       12        0
100.0% lib/auth/permission.ex                        120        8        0
100.0% lib/auth/person.ex                            373       58        0
100.0% lib/auth/repo.ex                                5        0        0
100.0% lib/auth/role.ex                              212       30        0
100.0% lib/auth/session.ex                           105       16        0
100.0% lib/auth/status.ex                             46        8        0
100.0% lib/auth/user_agent.ex                        101       25        0
100.0% lib/auth_web/controllers/api_controller.       70       19        0
100.0% lib/auth_web/controllers/app_controller.      111       36        0
100.0% lib/auth_web/controllers/auth_controller      507      141        0
100.0% lib/auth_web/controllers/init_controller       45        7        0
100.0% lib/auth_web/controllers/people_controll       34        8        0
100.0% lib/auth_web/controllers/permission_cont       61       19        0
100.0% lib/auth_web/controllers/ping_controller        8        1        0
100.0% lib/auth_web/controllers/role_controller      192       67        0
100.0% lib/auth_web/endpoint.ex                       54        0        0
100.0% lib/auth_web/gettext.ex                        24        0        0
100.0% lib/auth_web/plugs/is_owner.ex                 12        1        0
100.0% lib/auth_web/router.ex                        103       25        0
100.0% lib/auth_web/views/app_view.ex                  3        0        0
100.0% lib/auth_web/views/auth_view.ex                 3        0        0
100.0% lib/auth_web/views/error_view.ex               30        4        0
100.0% lib/auth_web/views/init_view.ex                 3        0        0
100.0% lib/auth_web/views/layout_view.ex               3        0        0
100.0% lib/auth_web/views/people_view.ex              35        7        0
100.0% lib/auth_web/views/permission_view.ex           3        0        0
100.0% lib/auth_web/views/role_view.ex                10        3        0
[TOTAL] 100.0%
----------------

Nelson's List automation moved this from In progress to Done Oct 17, 2022
@nelsonic nelsonic mentioned this issue Oct 17, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore a tedious but necessary task often paying technical debt help wanted If you can help make progress with this issue, please comment! tech-debt A feature/requirement implemented in a sub-optimal way & must be re-written technical A technical issue that requires understanding of the code, infrastructure or dependencies
Projects
Nelson's List
  
Done
Status: Done
Development

No branches or pull requests

1 participant