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(services): expand services test coverage #389

Merged
merged 14 commits into from
Sep 12, 2022
Merged

Conversation

nikoksr
Copy link
Owner

@nikoksr nikoksr commented Sep 12, 2022

Description

Took the time and added some more mocks and tests. Added mocks and tests for 4 services (msteams, amazonses, discord, slack).

Also added a new make command, namely mock. All mock does is wrap go generate ./.... Services from now on should include a line similar to this. This unifys the way that mocks are being generated and allows for quick re-generation of said mocks. Over time, additionally to adding more tests in general, more of the "older" tests should adapt this behavior, too.

Motivation and Context

Since Notify should ideally have as close to 100% test coverage as possible, this is a step that brings us closer to that goal.

How Has This Been Tested?

Ran the tests locally multiple times.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other Test

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

cc @svaloumas

Most services are testing by mocking them. To unify the way how and
where these mocks are being generated, I added the mock command. The
command executes go generate against all subdirectories internally. For
this to work every service needs a go:generate comment that defines the
mockery command to be executed. For examples, check
'service/amazonses/amazon_ses.go#14'. All newly added tests should make
use of this pattern.
@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2022

Codecov Report

Base: 55.91% // Head: 61.64% // Increases project coverage by +5.73% 🎉

Coverage data is based on head (3a41621) compared to base (cdd9171).
Patch coverage: 61.34% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #389      +/-   ##
==========================================
+ Coverage   55.91%   61.64%   +5.73%     
==========================================
  Files          21       29       +8     
  Lines         719      975     +256     
==========================================
+ Hits          402      601     +199     
- Misses        286      322      +36     
- Partials       31       52      +21     
Impacted Files Coverage Δ
service/amazonses/amazon_ses.go 93.18% <ø> (ø)
service/discord/discord.go 88.09% <ø> (ø)
service/slack/slack.go 92.85% <ø> (ø)
service/whatsapp/whatsapp.go 16.81% <0.00%> (+0.14%) ⬆️
service/msteams/mock_teams_client.go 48.14% <48.14%> (ø)
service/amazonses/mock_ses_client.go 60.00% <60.00%> (ø)
service/discord/mock_discord_session.go 60.86% <60.86%> (ø)
service/slack/mock_slack_client.go 74.28% <74.28%> (ø)
service/msteams/ms_teams.go 85.71% <100.00%> (ø)
... and 3 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@svaloumas svaloumas self-requested a review September 12, 2022 07:56
service/msteams/ms_teams_test.go Outdated Show resolved Hide resolved
service/msteams/ms_teams_test.go Show resolved Hide resolved
service/amazonses/amazon_ses_test.go Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
@svaloumas svaloumas merged commit cbc6fda into main Sep 12, 2022
@svaloumas svaloumas deleted the test/more-services branch September 12, 2022 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants