Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from revmischa/master
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use strict; | ||
use Test::More; | ||
use AnyMQ; | ||
use AnyMQ::Topic; | ||
|
||
my $bus = AnyMQ->new; | ||
|
||
my $t1 = AnyMQ::Topic->new( | ||
bus => $bus, | ||
publish_to_queues => 1, | ||
); | ||
test_topic($t1); | ||
|
||
my $t2 = AnyMQ::Topic->new( | ||
bus => $bus, | ||
publish_to_queues => 0, | ||
); | ||
test_topic($t2); | ||
|
||
sub test_topic { | ||
my ($channel) = @_; | ||
|
||
my $client = AnyMQ->new_listener($channel); | ||
|
||
my $events = 0; | ||
$client->poll(sub { $events++; }); | ||
|
||
$channel->publish({ data => 1}); | ||
|
||
my $expected = $channel->publish_to_queues ? 1 : 0; | ||
is($events, $expected, "Got expected events published to queues"); | ||
} | ||
|
||
done_testing; |