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 for Monika configuration codes #1279

Merged
merged 8 commits into from
Apr 26, 2024

Conversation

haricnugraha
Copy link
Contributor

@haricnugraha haricnugraha commented Apr 23, 2024

Monika Pull Request (PR)

What feature/issue does this PR add

Add tests for Monika configuration codes

How did you implement / how did you fix it

  1. Separate raw config type with validated and sanitized config to reduce conditional checks.
  2. Move initialize (read, parse, validate, sanitize and store) configuration function to the main function to improve readability.
  3. Extract functions to parsing, validating and sanitizing config.
  4. Extract function to watching config changes.
  5. Remove unnecessary code.

How to test

  1. Run npm test.
  2. Run npm run prod_test.
  3. Run in Symon mode and test with the following flow: Disabled -> Enabled -> Incident -> Recovery.

Demo

output.webm

Copy link

codecov bot commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 86.84211% with 30 lines in your changes are missing coverage. Please review.

Project coverage is 63.97%. Comparing base (6a29470) to head (507e0df).
Report is 6 commits behind head on main.

Files Patch % Lines
src/jobs/check-database.ts 35.71% 9 Missing ⚠️
src/components/config/validate.ts 73.68% 3 Missing and 2 partials ⚠️
src/components/config/parser/parse.ts 87.87% 2 Missing and 2 partials ⚠️
src/loaders/jobs.ts 50.00% 4 Missing ⚠️
src/components/config/watcher.ts 93.33% 2 Missing ⚠️
src/events/subscribers/application.ts 60.00% 2 Missing ⚠️
src/commands/monika.ts 85.71% 0 Missing and 1 partial ⚠️
src/components/config/create.ts 85.71% 0 Missing and 1 partial ⚠️
src/components/config/get.ts 97.22% 0 Missing and 1 partial ⚠️
src/jobs/summary-notification.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1279      +/-   ##
==========================================
+ Coverage   62.51%   63.97%   +1.46%     
==========================================
  Files         112      108       -4     
  Lines        3391     3362      -29     
  Branches      591      573      -18     
==========================================
+ Hits         2120     2151      +31     
+ Misses       1079     1030      -49     
+ Partials      192      181      -11     

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

@haricnugraha haricnugraha marked this pull request as ready for review April 24, 2024 11:00
Copy link
Contributor

@dennypradipta dennypradipta left a comment

Choose a reason for hiding this comment

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

Tested, can report and still receive probe changes. Nicely done

@haricnugraha haricnugraha merged commit 29bcb9e into hyperjumptech:main Apr 26, 2024
6 checks passed
@haricnugraha haricnugraha deleted the test/add-config-test branch April 26, 2024 08:05
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.

Failed to upload code coverage in GitHub Actions Cleanup SymonClient startup
3 participants