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

Migrate logging to use RPC Logging methods #102

Merged
merged 11 commits into from
Mar 27, 2020

Conversation

mo2menelzeiny
Copy link
Contributor

Summary

Migrates logging to use API Logging

Ticket Link

Closes #99

@codecov-io
Copy link

codecov-io commented Mar 23, 2020

Codecov Report

Merging #102 into master will increase coverage by 0.46%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #102      +/-   ##
==========================================
+ Coverage   40.28%   40.74%   +0.46%     
==========================================
  Files           6        6              
  Lines         561      562       +1     
==========================================
+ Hits          226      229       +3     
  Misses        313      313              
+ Partials       22       20       -2     
Impacted Files Coverage Δ
server/autolinkplugin/plugin.go 67.00% <25.00%> (-1.37%) ⬇️
server/autolinkplugin/config.go 73.61% <100.00%> (+5.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a10f0ee...433c563. Read the comment docs.

@hanzei hanzei added the 2: Dev Review Requires review by a core committer label Mar 23, 2020
Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

While touching the code it would be great to get some improvements in. Let me know if you are fine refining the code a bit more

server/autolinkplugin/config.go Outdated Show resolved Hide resolved
server/autolinkplugin/plugin.go Outdated Show resolved Hide resolved
@hanzei
Copy link
Contributor

hanzei commented Mar 23, 2020

@mo2menelzeiny Regarding your question on #99 (comment): No there are no test that cover these lines of code. FYI: You can see which lines are covered by running make coverage. If you want to add unit test for them, it would be highly appreciated, but this is no requirement for merging this PR.

Manually testing is quite hard, as the failure cases are hard to produce.

@mo2menelzeiny
Copy link
Contributor Author

@hanzei awesome, I will work on the requested refinements

In regards to the test coverage, I noticed that all the cases where there's a check on an error object are not covered in the unit tests, is this intentional?

Also I started writing some tests for config.go however I have some issues with some coupled dependencies that I'm not able to mock, like for example this line
https://github.com/mattermost/mattermost-plugin-autolink/blob/37ebe2af40d3a79042f94ae23af67ae0df4c27dc/server/autolinkplugin/config.go#L28
is there an easy way to mock the Compile() funciton? because it's depending on Config which is declared in the same scope not passed.
https://github.com/mattermost/mattermost-plugin-autolink/blob/37ebe2af40d3a79042f94ae23af67ae0df4c27dc/server/autolinkplugin/config.go#L21
any ideas on that matter?

@hanzei
Copy link
Contributor

hanzei commented Mar 23, 2020

In regards to the test coverage, I noticed that all the cases where there's a check on an error object are not covered in the unit tests, is this intentional?

No that is not intentional, this are just missing tests 😉

@hanzei
Copy link
Contributor

hanzei commented Mar 23, 2020

Mocking is one way of testing, another would be to just test the error case. In this case an invalid pattern would cause an error:
https://github.com/mattermost/mattermost-plugin-autolink/blob/37ebe2af40d3a79042f94ae23af67ae0df4c27dc/server/autolink/autolink.go#L81-L83

Used logging fields

Added tests for config errors

Added meaningful messages to channel and team errors
Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

Heads up that there is a conflict to resolve

server/autolinkplugin/plugin.go Outdated Show resolved Hide resolved
server/autolinkplugin/plugin.go Outdated Show resolved Hide resolved
server/autolinkplugin/config_test.go Outdated Show resolved Hide resolved
@mo2menelzeiny mo2menelzeiny requested a review from hanzei March 24, 2020 21:12
Copy link
Contributor

@hanzei hanzei left a comment

Choose a reason for hiding this comment

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

Nice 👍

@hanzei hanzei requested a review from levb March 24, 2020 22:45
Copy link
Contributor

@levb levb left a comment

Choose a reason for hiding this comment

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

Nice!

server/autolinkplugin/config_test.go Outdated Show resolved Hide resolved
@levb levb requested a review from DHaussermann March 25, 2020 13:17
@levb levb added 3: QA Review Requires review by a QA tester and removed 2: Dev Review Requires review by a core committer labels Mar 25, 2020
@levb
Copy link
Contributor

levb commented Mar 25, 2020

@DHaussermann this can use a general smoke test (and maybe checking that at least some errors are actually logged?) - perhaps bundled in with the release test?

Copy link

@DHaussermann DHaussermann left a comment

Choose a reason for hiding this comment

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

@mo2menelzeiny Thanks for this enhancment!

I did some regression testing of this PR. No issues found.

As mentioned above, it seems difficult to hit these cases and see the actual logging occur.
LGTM!

@levb I agree we should merge this.

@DHaussermann DHaussermann added 4: Reviews Complete All reviewers have approved the pull request QA Review Done PR has been approved by QA and removed 3: QA Review Requires review by a QA tester labels Mar 26, 2020
@hanzei hanzei merged commit 4a25236 into mattermost-community:master Mar 27, 2020
@mo2menelzeiny
Copy link
Contributor Author

awesome job guys, thank you!
@hanzei, @levb, @DHaussermann

@jfrerich jfrerich mentioned this pull request Mar 31, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request QA Review Done PR has been approved by QA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate logging to use RPC Logging methods
6 participants