[SCM] libmessage-passing-perl Debian packaging branch, master, updated. debian/0.111-3-14-g44f6e88
Tomas Doran
bobtfish at bobtfish.net
Mon May 6 11:56:38 UTC 2013
The following commit has been merged in the master branch:
commit 75fd9585be842496ba8dc501e573c07d643beeae
Author: Tomas Doran <bobtfish at bobtfish.net>
Date: Sat Feb 25 11:33:15 2012 +0000
Callback in the test consumer
diff --git a/.gitignore b/.gitignore
index 5bc14e2..aa56734 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
+*.swp
META.yml
META.json
MYMETA.yml
diff --git a/lib/Log/Stash/Output/Test.pm b/lib/Log/Stash/Output/Test.pm
index aa44e32..0e1b9e2 100644
--- a/lib/Log/Stash/Output/Test.pm
+++ b/lib/Log/Stash/Output/Test.pm
@@ -15,6 +15,18 @@ has messages => (
lazy => 1,
);
+has on_consume_cb => (
+ isa => 'CodeRef',
+ is => 'ro',
+ predicate => '_has_on_consume_cb',
+);
+
+after consume => sub {
+ my ($self, $msg) = @_;
+ $self->on_consume_cb->($msg)
+ if $self->_has_on_consume_cb;
+};
+
with 'Log::Stash::Mixin::Output';
__PACKAGE__->meta->make_immutable;
diff --git a/t/output_test.t b/t/output_test.t
index c608ea5..c30022f 100644
--- a/t/output_test.t
+++ b/t/output_test.t
@@ -5,7 +5,9 @@ use Try::Tiny;
use Log::Stash::Output::Test;
-my $test = try { Log::Stash::Output::Test->new }
+my $called = 0;
+
+my $test = try { Log::Stash::Output::Test->new(on_consume_cb => sub { $called++ }) }
catch { fail "Failed to construct $_" };
ok $test;
@@ -14,6 +16,7 @@ try { $test->consume('message') }
is $test->messages_count, 1;
is_deeply [$test->messages], ['message'];
+is $called, 1;
try { $test->clear_messages }
catch { fail "Could not clear messages: $_" };
@@ -21,6 +24,5 @@ try { $test->clear_messages }
is $test->messages_count, 0;
is_deeply [$test->messages], [];
-
done_testing;
--
libmessage-passing-perl Debian packaging
More information about the Pkg-perl-cvs-commits
mailing list