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

test: add tests to improve code coverage for logging #244

Closed
wants to merge 2 commits into from

Conversation

emeeker2002
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Jul 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.08%. Comparing base (15705da) to head (bc4c05b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #244      +/-   ##
==========================================
+ Coverage   36.51%   37.08%   +0.56%     
==========================================
  Files          55       55              
  Lines        4017     4021       +4     
==========================================
+ Hits         1467     1491      +24     
+ Misses       2458     2440      -18     
+ Partials       92       90       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@emeeker2002 emeeker2002 force-pushed the code-coverage branch 13 times, most recently from 650fcd3 to 9d0d626 Compare July 1, 2024 22:52
@emeeker2002
Copy link
Contributor Author

Got the logger test working with all checks passed except for the Console API Tests / build (pull_request) (Won't work right for now)

Copy link
Member

@rsdmike rsdmike left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this I think we've got some other issues at work here. Namely, the logging level doesn't seem to be working correctly. Looks to be an issue from the template we used. I know this is a code coverage task, but lets take a stab at using the interface provided in this issue: evrone/go-clean-template#148 . We shouldnt need to have if conditions in our code as that would sort of eliminate the job of what the logging library should do. Can we take a stab at copying and pasting that and updating the code to use it?

type loggerTest struct {
name string
logLevel string
testFunction func(t *testing.T, log *Logger, buf *bytes.Buffer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey @emeeker2002 typically you'd want to have an expected result in your test struct. and then in each test case, you'd set the expected result. That way all assets can be handled in the for loop at the end.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would explain why the linter was wanting t.Helper in each function which was a bit odd to me.

Copy link
Contributor

@matt-primrose matt-primrose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update test struct and assert handling based on feedback in comment

@rsdmike
Copy link
Member

rsdmike commented Jul 3, 2024

closed in place of #249 due to @emeeker2002 on vacation.

@rsdmike rsdmike closed this Jul 3, 2024
@rsdmike rsdmike deleted the code-coverage branch July 3, 2024 20:15
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

Successfully merging this pull request may close these issues.

4 participants