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(notifier): create tests for notifier and its redis helper #338

Merged
merged 35 commits into from
Feb 2, 2025

Conversation

e11sy
Copy link
Contributor

@e11sy e11sy commented Dec 25, 2024

Testcases

RedisHelper

  • should connect to redis client
  • should close redis client
  • should not throw error on close if client is already closed
  • should return event count
  • should reset counter and timestamp if threshold period is expired

Notifier

  • should send task if event threshold reached
  • should not send task if event count is more than event threshold
  • should not send task if event count is less than event threshold
  • should not check for event count and should not send event to sender if rule is disabled
  • should not check for event count and should not send event to sender if rule validation did not pass
  • should send event to all channels that are enabled in rule

workers/notifier/tests/worker.test.ts Outdated Show resolved Hide resolved
workers/notifier/tests/worker.test.ts Outdated Show resolved Hide resolved
@e11sy e11sy changed the title chore(notifier-tests): create tests for notifier and its redis helper test(notifier): create tests for notifier and its redis helper Jan 3, 2025
@e11sy e11sy merged commit 0ef30b2 into notifier-refactoring Feb 2, 2025
2 of 3 checks passed
@e11sy e11sy deleted the notifier-tests-improvements branch February 2, 2025 21:18
neSpecc added a commit that referenced this pull request Feb 3, 2025
* add redis helper for notifier worker

- added redis helper class and some methods for digest and threshold storing
- added env.sample for redis connections
- added dependencies related to redis

* add notifier methods for threshold evaluation

- add notifier method to get threshold from redis or from db
- add notifier method to check if event is critical
- updated lock

* clean up in notifier

* get rid of the buffer

- get rid of the buffer
- move types to types directory
- improve old comments

* fix lint issues

* refactor notifier and tests

* refactor notifier and tests

* lint fix and remove redundant

* remove unneeded database connection

* improve naming and lua logic

* implement redis testcontainer

* refactor notifier tests with testcontainer

* lint fix

* typo fix

* update lock file

* fix lua script and naming

* move Date.now() to variables

* fix(notifier): fix notifier tests

* fix(sender): fix sender type references

* imp(notifier): improve redis structure key

* imp(comments): improve docs

* test(notifier): create tests for notifier and its redis helper (#338)

* update lock file

* added tests for worker and redisHelper

* typo

* imp(notifier): improved testcase of the redis helper

* fix(notifier-tests): afterall quit from redis

* test(notifier-validator): remove check what to receive validation

* feat(notifier-types): what to reveive All changed to SeenMore

* test(notifier): restore RedisHelper original implementation before each test

Added new testcases
- should send event to channels at most once in one threshold period for one fitted rule, no matter how much events have passed
- should compute event count for period for each fitted rule

* revert: remove check what to receive validator

* test(notifier): add testcase for new events

* feat(notifier): add check for new events

* lint fix

* fix tests

* test(notifier-worker): improve readability

* test(notifier-worker): improve testcase

* test(notifier-worker): improve testacase description

* test(notifier-worker): improve testcase readability

* test(notifier-worker): improve test description

* but(): all bugs fixed

* feat(): all features added

* chore(): restore all bugs

* bug(notifier): fix bug with channel enabled validation

* update yarn.lock

* fix tests

* imp(notifier): updater redis structure key format

* Update extensions.ts

* improve docs

* remove empty lines

* fix(notifier): fix notifier redisHelper tests

* fix(notifer): notifier redisHelpers tests fix

* fix(notifier): fix notifier redisHelper test

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
neSpecc added a commit that referenced this pull request Feb 3, 2025
* chore(logs): add logs and try catch blocks (#347)

* Update redisHelper.ts

* Update runner.ts

* try-catch and logs to runner and redisHelper

* Update runner.ts

* fix: not increment affected users if user is not provided (#344)

* feat(notifier): new notification pattern (#326)

* add redis helper for notifier worker

- added redis helper class and some methods for digest and threshold storing
- added env.sample for redis connections
- added dependencies related to redis

* add notifier methods for threshold evaluation

- add notifier method to get threshold from redis or from db
- add notifier method to check if event is critical
- updated lock

* clean up in notifier

* get rid of the buffer

- get rid of the buffer
- move types to types directory
- improve old comments

* fix lint issues

* refactor notifier and tests

* refactor notifier and tests

* lint fix and remove redundant

* remove unneeded database connection

* improve naming and lua logic

* implement redis testcontainer

* refactor notifier tests with testcontainer

* lint fix

* typo fix

* update lock file

* fix lua script and naming

* move Date.now() to variables

* fix(notifier): fix notifier tests

* fix(sender): fix sender type references

* imp(notifier): improve redis structure key

* imp(comments): improve docs

* test(notifier): create tests for notifier and its redis helper (#338)

* update lock file

* added tests for worker and redisHelper

* typo

* imp(notifier): improved testcase of the redis helper

* fix(notifier-tests): afterall quit from redis

* test(notifier-validator): remove check what to receive validation

* feat(notifier-types): what to reveive All changed to SeenMore

* test(notifier): restore RedisHelper original implementation before each test

Added new testcases
- should send event to channels at most once in one threshold period for one fitted rule, no matter how much events have passed
- should compute event count for period for each fitted rule

* revert: remove check what to receive validator

* test(notifier): add testcase for new events

* feat(notifier): add check for new events

* lint fix

* fix tests

* test(notifier-worker): improve readability

* test(notifier-worker): improve testcase

* test(notifier-worker): improve testacase description

* test(notifier-worker): improve testcase readability

* test(notifier-worker): improve test description

* but(): all bugs fixed

* feat(): all features added

* chore(): restore all bugs

* bug(notifier): fix bug with channel enabled validation

* update yarn.lock

* fix tests

* imp(notifier): updater redis structure key format

* Update extensions.ts

* improve docs

* remove empty lines

* fix(notifier): fix notifier redisHelper tests

* fix(notifer): notifier redisHelpers tests fix

* fix(notifier): fix notifier redisHelper test

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

---------

Co-authored-by: Peter <specc.dev@gmail.com>
Co-authored-by: Vyacheslav Chernyshev <81693471+slaveeks@users.noreply.github.com>
Co-authored-by: e11sy <130844513+e11sy@users.noreply.github.com>
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.

2 participants