Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Message::Passing dispatcher

Signed-off-by: Pedro Melo <melo@simplicidade.org>
  • Loading branch information...
commit 531efff75931a71d99f712ad9e7bd29902709e5d 1 parent fdb49b1
@melo authored
View
15 lib/Log/Logan/Dispatch/Message/Passing.pm
@@ -0,0 +1,15 @@
+package Log::Logan::Dispatch::Message::Passing;
+
+use Moo::Role;
+use namespace::clean;
+
+requires 'build_message_passing_dispatcher';
+
+has '_mp_output' => (is => 'lazy', builder => 'build_message_passing_dispatcher');
+
+sub dispatch {
+ shift->_mp_output->consume(shift);
+}
+
+
+1;
View
27 t/20-dispatch-message-passing.t
@@ -0,0 +1,27 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More;
+use Test::Deep;
+use lib 't/tlib';
+use T::MessagePassing::Logan;
+
+
+subtest 'basic events' => sub {
+ my $lg = T::MessagePassing::Logan->new;
+ my $to = $lg->_mp_output; ## Private, just for test purposes
+ my $l = $lg->session;
+
+ is($to->message_count, 0, 'no messages recorded at start');
+
+ $l->event({ class => 'c', subclass => 'cs' });
+ cmp_deeply(
+ [$to->messages],
+ [superhashof({ class => 'c', subclass => 'cs', category => 'main' })],
+ 'event() sent a proper message'
+ );
+};
+
+
+done_testing();
View
11 t/tlib/T/MessagePassing/Logan.pm
@@ -0,0 +1,11 @@
+package T::MessagePassing::Logan;
+
+use Moo;
+extends 'Log::Logan';
+with 'Log::Logan::Dispatch::Message::Passing';
+
+use Message::Passing::Output::Test;
+
+sub build_message_passing_dispatcher { Message::Passing::Output::Test->new }
+
+1;
Please sign in to comment.
Something went wrong with that request. Please try again.