-
Notifications
You must be signed in to change notification settings - Fork 1
feat(tests): add table-driven tests for Consumer struct #53
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
Draft
rossnelson
wants to merge
15
commits into
main
Choose a base branch
from
add-nats-js-consumer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added table-driven tests for NewConsumer, SetLogger, SetConnector, SetStrategy, SetDLQHandler, SetProcessor, Setup, IsRunning, Stop, and Validate functions. - Used testify's assert package for matchers to avoid if statements. - Included mock implementations for Logger, Connector, Strategy, and DLQHandler.
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
- Added a new Cobra command to run a NATS consumer. - Implemented the consumer setup and start logic. - Integrated with the existing logger and connection manager. - Added mock implementations for unit testing. - Removed unused EnableDLQ configuration.
- Added pull-based consumer strategy for NATS JetStream - Added NATS service configuration with TLS support - Added certificate generation script - Updated consumer example to use the new strategy - Added .gitignore rule for certificate files
…integration - Add publisher command to simian-go CLI for publishing test messages to NATS - Fix circuit breaker logger to use configured logger instead of global - Update NATS consumer interface to require Debugf method - Add debug logging to message acknowledgement - Improve consumer example to properly process messages
- Integrated circuit breaker into PullStrategy to handle message consumption failures. - Added circuit breaker configuration to PullStrategy's Config struct. - Implemented circuit breaker checks and recording in the Consume method. - Updated consumer example to include circuit breaker initialization.
Properly capture and propagate the exit code from go test to ensure GitHub Actions fails when tests fail, while still generating junit reports. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ensure pull strategy can reconnect when the connection manager loses and recreates its connection. Previously, the strategy would fail to recover when the JetStream object was recreated. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Moved consumer creation logic to a new `createConsumer` method - Updated `Setup` and `ensureConsumerActive` methods to use `createConsumer` - Added new `connection` package for shared connection management - Refactored `consumer` package to use shared connection and modularized setup - Improved logging in `processor` function
- Replaced inline mock dependencies with reusable mock dependencies from conmock package. - Updated tests in natsjscon_test.go to use new mock dependencies. - Added new tests for natsjsstrategypull package. - Created new mock implementations for jetstream.Consumer and other interfaces in natsjscm package. - Refactored existing mocks to follow a consistent naming convention.
- Implemented MockMessageBatch to mock MessageBatch interface. - Added NewMockMessageBatch constructor to create mock instances. - Updated NewDependencies to include MockMessageBatch. - Modified TestConsume to use MockMessageBatch for testing.
- Removed locking in the Stop method of Consumer to prevent deadlocks. - Added a test case to ensure Stop method does not panic.
- Added tests to validate Consumer configuration in natsjscon package. - Ensured tests cover invalid processor, connector, stream name, consumer name, and subject. - Updated Dependencies.NewConsumer to accept optional ConsumerConfig.
- Replace ReconnectHandler with DisconnectHandler in ConnectionManager - Remove handleReconnect method and inline JetStream context creation - Change Processor and ConsumptionStrategy to use channels for messages - Update tests and mocks to reflect new message handling approach - Add default case in handleResult to log unknown process status
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SetStrategy, SetDLQHandler, SetProcessor, Setup, IsRunning, Stop,
and Validate functions.
and DLQHandler.