chore: adding eventbus/base/kafka tests #2750
Closed
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.
Adding tests for
eventbus/base/kafka.go:
func TestBrokers
The Brokers method basically splits the comma-separated broker URLs and return them as a slice of strings.
In the test:
A sample
eventbusv1alpha1.KafkaBus
configuration is created with two broker URLs: "broker1:9092" and "broker2:9092".Then the Brokers method of the created kafka instance is called to get the actual list of broker addresses. This test will ensure that the Brokers method correctly parses the comma-separated broker URLs and returns them as a list of strings.
func TestConfig
This test is verifying the behavior of the
Config
func in the context of the Kafka struct. The Config func is responsible for generating asarama.Config
instance with specific configuration settings based on the KafkaBus configuration. It's validating that the logic for translating the higher-level configuration to the lower-level Kafka client library's configuration is working.func TestConfig_NoSASL
This test is checking the behavior when SASL configuration is not provided, by setting SASL to nil.
func TestNewKafka
This test validates the
NewKafka
func, which initializes akafka
object with a given configuration and logger. It ensures that thekafka
object and its logger are properly initialized.