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

Consumer testing not possible when using macros #266

Closed
lentex opened this issue Mar 1, 2024 · 1 comment · Fixed by #267
Closed

Consumer testing not possible when using macros #266

lentex opened this issue Mar 1, 2024 · 1 comment · Fixed by #267
Assignees
Labels
bug Something isn't working

Comments

@lentex
Copy link
Contributor

lentex commented Mar 1, 2024

Hey there, it's me again :)

Testing a consumer works perfectly fine when sticking to the provided example:
https://junges.dev/documentation/laravel-kafka/v1.13/testing/7-mocking-your-kafka-consumer

Although when using a macro for the consumer the code in the handler callback is not executed at all.

So instead of

$consumer = Kafka::createConsumer(['mark-post-as-published-topic'])
    ->withHandler(function (KafkaConsumerMessage $message) {
        // business logic
    })->build();

I use a macro like this:

$consumer = Kafka::consumer('mark-post-as-published-topic')
    ->withHandler(function (KafkaConsumerMessage $message) {
        // business logic
    })->build();

The macro only adds SASL to the consumer:

Kafka::macro('consumer', function (string $topic) use ($sasl) {
    return $this->createConsumer([$topic])->withSasl($sasl);
});

Please help!
Thanks in advance

@lentex lentex added the bug Something isn't working label Mar 1, 2024
@mateusjunges mateusjunges linked a pull request Mar 7, 2024 that will close this issue
@mateusjunges
Copy link
Owner

Hey @lentex thanks for reporting this. I fixed the issue for v2, will work on a fix for v1.13.x later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants