File Coverage

lib/Log/Shiras/Test2.pm
Criterion Covered Total %
statement 100 132 75.7
branch 17 32 53.1
condition 10 17 58.8
subroutine 19 21 90.4
pod 6 7 85.7
total 152 209 72.7


line stmt bran cond sub pod time code
1             package Log::Shiras::Test2;
2             our $AUTHORITY = 'cpan:JANDREW';
3 5     5   2699 use version 0.77; our $VERSION = version->declare("v0.44.0");
  5         95  
  5         27  
4             #~ use lib '../../';
5             #~ use Log::Shiras::Unhide qw( :InternalLoGShiraSTesT );
6             ###InternalLoGShiraSTesT warn "You uncovered internal logging statements for Log::Shiras::Test2-$VERSION";
7 5     5   387 use 5.010;
  5         11  
8 5     5   16 use utf8;
  5         5  
  5         30  
9 5     5   78 use Moose;
  5         6  
  5         33  
10 5     5   21521 use MooseX::StrictConstructor;
  5         8  
  5         34  
11 5     5   9723 use MooseX::HasDefaults::RO;
  5         80  
  5         36  
12 5     5   15256 use Test2::API qw/context/;
  5         8  
  5         286  
13 5     5   22 use MooseX::Types::Moose qw( RegexpRef Bool ArrayRef );
  5         5  
  5         49  
14 5     5   16355 use Data::Dumper;
  5         7  
  5         225  
15             use lib
16 5         29 '../../../lib',
17 5     5   19 '../lib';
  5         6  
18 5     5   564 use Log::Shiras::Switchboard 0.029;
  5         121  
  5         27  
19 5     5   278 use Log::Shiras::Types qw( PosInt );
  5         8  
  5         32  
20              
21             our $last_buffer_position = 11;# This one goes to eleven :^|
22              
23             #########1 Public Attributes 3#########4#########5#########6#########7#########8#########9
24              
25             has keep_matches =>(
26             isa => Bool,
27             default => 0,
28             writer => 'set_match_retention',
29             );
30              
31             has test_buffer_size =>(
32             isa => PosInt,
33             default => sub{ $last_buffer_position },#
34             writer => 'change_test_buffer_size',
35             trigger => \&_set_buffer_size,
36             );
37              
38              
39             #########1 Public Methods 3#########4#########5#########6#########7#########8#########9
40              
41             sub get_buffer{
42 1     1 1 2 my ( $self, $report_name ) = @_;
43             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
44             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::get_buffer',
45             ###InternalLoGShiraSTesT message =>[ "getting the buffer for: $report_name" ], } );
46 1         1 my $buffer_ref = [];
47 1 50       3 if( $self->_has_test_buffer( $report_name ) ){
48 1         26 $buffer_ref = $self->_get_test_buffer( $report_name );
49             }
50             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
51             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::get_buffer',
52             ###InternalLoGShiraSTesT message =>[ "returning: $buffer_ref" ], } );
53 1         15 return $buffer_ref;
54             }
55              
56             #########1 Test Methods 3#########4#########5#########6#########7#########8#########9
57              
58             sub clear_buffer{
59 0     0 1 0 my ( $self, $report_name, $test_description ) = @_;
60             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
61             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::clear_buffer',
62             ###InternalLoGShiraSTesT message =>[ "Reached clear_buffer for : $report_name" ], } );
63 0         0 $self->_set_test_buffer( $report_name => [] );
64 0         0 my $ctx = context();
65 0         0 $ctx->ok(1, $test_description);
66 0         0 $ctx->release;
67 0         0 return $report_name;
68             }
69              
70             sub has_buffer{
71 0     0 1 0 my ( $self, $report_name, $expected, $test_description ) = @_;
72             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
73             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::has_buffer',
74             ###InternalLoGShiraSTesT message =>[ "Reached has_buffer for report: $report_name",
75             ###InternalLoGShiraSTesT "........with expected outcome: $expected",
76             ###InternalLoGShiraSTesT "..........and primary message: $test_description" ], } );
77 0         0 my $ctx = context();
78 0         0 my $result = $self->_has_test_buffer( $report_name );
79             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
80             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::has_buffer',
81             ###InternalLoGShiraSTesT message =>[ "resulting in: $result" ], } );
82 0         0 $ctx->ok( $result == $expected, $test_description);
83 0 0       0 if( $result != $expected ){
84 0 0       0 if( !$result ){
85 0         0 $ctx->diag( "Expected to find a buffer for -$report_name- but it didn't exist" );
86             }else{
87 0         0 $ctx->diag( "A buffer for -$report_name- was un-expectedly found" );
88             }
89             }
90 0         0 $ctx->release;
91 0         0 return $report_name;
92             }
93              
94             sub buffer_count{
95 1     1 1 2 my ( $self, $report_name, $guess, $test_description ) = @_;
96             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
97             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::buffer_count',
98             ###InternalLoGShiraSTesT message =>[ "testing the row count loaded in the buffer ...",
99             ###InternalLoGShiraSTesT "for : $report_name",
100             ###InternalLoGShiraSTesT "with guess: $guess" ], } );
101 1         3 my $ctx = context();
102 1         43 my $actual_count = scalar( @{$self->get_buffer( $report_name )} );
  1         2  
103 1         4 $ctx->ok($actual_count == $guess, $test_description);
104 1 50       177 if( $actual_count != $guess ){
105 0         0 $ctx->diag( "Expected -$guess- items in the buffer but found -$actual_count- items" );
106             }
107 1         3 $ctx->release;
108 1         15 return $report_name;
109             }
110              
111             sub match_message{
112 19     19 1 4045 my ( $self, $report_name, $line, $test_description ) = @_;
113 19         31 chomp $line;
114 19   50     44 $test_description //= '';
115             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
116             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
117             ###InternalLoGShiraSTesT message =>[ "Reached match_output",
118             ###InternalLoGShiraSTesT "for : $report_name",
119             ###InternalLoGShiraSTesT "testing line : $line",
120             ###InternalLoGShiraSTesT "with explanation: $test_description" ] } );
121 19         42 my $ctx = context();
122 19         847 my $result = 0;
123 19         20 my @failarray;
124             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
125             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
126             ###InternalLoGShiraSTesT message =>[ "Check if the buffer exists" ] } );
127 19 50       83 if( $self->_has_test_buffer( $report_name ) ){
128             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
129             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
130             ###InternalLoGShiraSTesT message =>[ "The buffer exists" ] } );
131 19         386 my @buffer_list = @{$self->_get_test_buffer( $report_name )};
  19         56  
132             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
133             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
134             ###InternalLoGShiraSTesT message =>[ "The buffer list is:", @buffer_list ] } );
135 19         342 @failarray = (
136             'Expected to find: ', $line,
137             "but could not match it to data in -$report_name-..."
138             );
139 19 50       34 if( !@buffer_list ){
140             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
141             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
142             ###InternalLoGShiraSTesT message =>[ "The buffer list is EMPTY!", ] } );
143 0         0 push @failarray, 'Because the test buffer is EMPTY!';
144             }else{
145 19         24 my $position = 0;
146 19         24 TESTALL: for my $buffer_message ( @buffer_list ){
147 19         25 my $buffer_array_ref = $buffer_message->{message};
148             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
149             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
150             ###InternalLoGShiraSTesT message =>[ "testing line:", $buffer_array_ref, ] } );
151 19         22 for my $ref_element ( @$buffer_array_ref ){
152 21 50 33     219 if( !$ref_element or length( $ref_element ) == 0 ){
    100 100        
      100        
153             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
154             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
155             ###InternalLoGShiraSTesT message =>[ "Nothing to match in this message", ] } );
156             }elsif( ( is_RegexpRef( $line ) and $ref_element =~ $line ) or
157             ( $ref_element eq $line ) ){
158             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
159             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
160             ###InternalLoGShiraSTesT message =>[ "Found a match!", ] } );
161 19 100       2760 splice( @buffer_list, $position, 1 ) if !$self->keep_matches;
162 19         25 $result = 1;
163 19         38 last TESTALL;
164             }else{
165             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
166             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
167             ###InternalLoGShiraSTesT message =>[ "No Match Here", ] } );
168 2         246 push @failarray, "---" . Dumper( $ref_element );
169             }
170             }
171 0         0 $position++;
172             }
173             }
174             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
175             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
176             ###InternalLoGShiraSTesT message =>[ "The match test result is: $result", ] } );
177 19 50       51 if( $result ){
178             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
179             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
180             ###InternalLoGShiraSTesT message =>[ "Reloading the updated buffer", ] } );
181 19         69 $self->_set_test_buffer( $report_name => [@buffer_list] );
182             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
183             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
184             ###InternalLoGShiraSTesT message =>[ "Updates complete", ] } );
185             }
186             } else {
187 0         0 my $message = "The master test buffer does not contain: $report_name";
188             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
189             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
190             ###InternalLoGShiraSTesT message =>[ $message ], } );
191 0         0 @failarray = ( $message );
192             }
193             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
194             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::match_message',
195             ###InternalLoGShiraSTesT message =>[ "passing result to Test2::API: $result" ], } );
196 19         301 $ctx->ok($result, $test_description);
197 19 50       3115 if( !$result ) {
198 0         0 map{ $ctx->diag( $_ ) } @failarray;
  0         0  
199 0         0 $report_name = 0;
200             }
201 19         52 $ctx->release;
202 19         308 return $report_name;
203             }
204              
205             sub cant_match_message{
206 12     12 1 4172 my ( $self, $report_name, $line, $test_description ) = @_;
207             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
208             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
209             ###InternalLoGShiraSTesT message =>[ "Reached cant_match_output",
210             ###InternalLoGShiraSTesT "for : $report_name",
211             ###InternalLoGShiraSTesT "testing line : $line",
212             ###InternalLoGShiraSTesT "with explanation: $test_description" ] } );
213 12         29 my $ctx = context();
214 12         530 my $result = 1;
215 12         13 my $i = 0;
216 12         14 my @failarray;
217             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
218             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
219             ###InternalLoGShiraSTesT message =>[ "Checking if the buffer exists" ] } );
220 12 100       38 if( $self->_has_test_buffer( $report_name ) ){
221             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
222             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
223             ###InternalLoGShiraSTesT message =>[ "The buffer exists" ] } );
224 10         185 my @buffer_list = @{$self->_get_test_buffer( $report_name )};
  10         25  
225             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
226             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
227             ###InternalLoGShiraSTesT message =>[ "The buffer list is:", @buffer_list ] } );
228 10         179 TESTMISS: for my $test_line ( @buffer_list) {
229 4         7 $test_line = $test_line->{message};
230             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
231             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
232             ###InternalLoGShiraSTesT message =>[ "testing line:", $test_line, ] } );
233 4 50       15 if( is_ArrayRef( $test_line ) ){
234             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
235             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
236             ###InternalLoGShiraSTesT message =>[ "Message line already an ArrayRef - do nothing", ] } );
237             }else{
238             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
239             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
240             ###InternalLoGShiraSTesT message =>[ "Making the buffer line an ArrayRef", ] } );
241 0         0 $test_line = [ $test_line ];
242             }
243 4         515 for my $ref_element ( @$test_line ){
244 4 50 33     10 if( ( is_RegexpRef( $line ) and $ref_element =~ $line ) or
      33        
245             ( $ref_element eq $line ) ){
246             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
247             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
248             ###InternalLoGShiraSTesT message =>[ "Found a match! (BAD)", ] } );
249 0         0 $result = 0;
250 0         0 push @failarray, (
251             "For the -$report_name- buffer a no match condition was desired",
252             "for the for the test -$line-",
253             "a match was found at position -$i-",
254             "(The line was not removed from the buffer!)"
255             );
256 0         0 last TESTMISS;
257 0         0 $result = 1;
258             }else{
259             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
260             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
261             ###InternalLoGShiraSTesT message =>[ "No Match For: $ref_element", ] } );
262 4         468 $i++;
263             }
264             }
265             }
266 10 50       26 if( $result ) {
267             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
268             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
269             ###InternalLoGShiraSTesT message =>[ "Test buffer exists but the line was not found in: $report_name", ] } );
270             }
271             } else {
272             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 1,
273             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::cant_match_message',
274             ###InternalLoGShiraSTesT message =>[ "Pass! no buffer found ...", ] } );
275             }
276 12         77 $ctx->ok($result, $test_description);
277 12 50       1780 if( !$result ) {
278 0         0 map{ $ctx->diag( $_ ) } @failarray;
  0         0  
279 0         0 $report_name = 0;
280             }
281 12         31 $ctx->release;
282 12         186 return $report_name;
283             }
284              
285             #########1 Private Attributes 3#########4#########5#########6#########7#########8#########9
286              
287             has _switchboard_link =>(# Use methods from the Switchboard singleton
288             isa => 'Log::Shiras::Switchboard',
289             reader => '_get_switchboard',
290             handles =>[ qw(
291             _has_test_buffer _get_test_buffer _set_test_buffer
292             master_talk _clear_all_test_buffers
293             ) ],
294             default => sub{ Log::Shiras::Switchboard->get_operator(); },
295             );
296              
297             #########1 Private Methods 3#########4#########5#########6#########7#########8#########9
298              
299             after 'change_test_buffer_size' => \&_set_buffer_size;
300              
301             sub _set_buffer_size{
302 2     2   4 my ( $self, $new_size ) = @_;
303             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 0,
304             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::_set_buffer_size',
305             ###InternalLoGShiraSTesT message =>[ "setting the new test buffer size to: $new_size" ], } );
306 2         34 $last_buffer_position = $new_size;
307             }
308              
309             sub DEMOLISH{
310 5     5 0 9 my ( $self, ) = @_;
311             ###InternalLoGShiraSTesT $self->master_talk( { report => 'log_file', level => 3,
312             ###InternalLoGShiraSTesT name_space => 'Log::Shiras::Switchboard::DEMOLISH',
313             ###InternalLoGShiraSTesT message =>[ "clearing ALL the test buffers" ], } );
314 5         24 $self->_clear_all_test_buffers;
315             }
316              
317             #########1 Phinish 3#########4#########5#########6#########7#########8#########9
318              
319 5     5   18953 no Moose;
  5         8  
  5         27  
320             __PACKAGE__->meta->make_immutable;
321              
322             1;
323             # The preceding line will help the module return a true value
324              
325             #########1 main pod docs 3#########4#########5#########6#########7#########8#########9
326             __END__
327              
328             =head1 NAME
329              
330             Log::Shiras::Test2 - Test2 for traffic in the ::Switchboard
331              
332             =head1 SYNOPSIS
333            
334             use Test2::Bundle::Extended qw( !meta );
335             use Test2::Plugin::UTF8;
336             use Test::Log::Shiras;
337             plan( 3 );
338            
339             ~~ Set up the Log::Shiras::Switchboard operator here ($ella_peterson) ~~
340            
341             my $test_class;
342             ok( lives{ $test_class = Log::Shiras::Test2->new },
343             "Build a test class for reading messages from the bat phone" ) or note($@);;
344             ok( lives{
345             $ella_peterson->master_talk({ # Use Ella Petersons bat phone
346             name_space => 'main', report => 'report1', level => 'eleven',
347             message =>[ 'Hello World' ], });
348             }, "Test making a call (with Ella Petersons bat phone)" ) or note($@);
349             $test_class->match_message( 'report1', "Hello World",
350             "... and check the output" );
351            
352             =head1 DESCRIPTION
353              
354             This is a class used for testing. It inherits directly from L<Test2::API> without going through
355             Test::Builder. This will feed back to any Test2 rooted test with the understanding that even
356             Test::More now uses Test2 Under the hood. The tests are object oriented methods rather than
357             functions. That was a conscious choice in order to auto link to the singleton once without
358             re-connecting over and over. The goal is to be able to set up messages to the switchboard with
359             minimum wiring to the reports and still be able to see if the messages are working as expected.
360             Log::Shiras::Switchboard will actually check if this module is active and store messages to a test
361             buffer right before sending them to the reports. This allows the reports to exist in name only
362             and to still test permissions levels and caller actions without using L<Capture::Tiny> or reading
363             output files for test results.
364              
365             =head2 Attributes
366              
367             These are things that can be passed to the ->new argument in order to change the general behavior
368             of the test instance.
369              
370             =head3 keep_matches
371              
372             =over
373              
374             B<Description:> This determines whether a match is deleted from the test buffer when it is matched
375             by the test L<match_message|/match_message( $report, $test_line, $message )>.
376              
377             B<Range:> accepts a boolean value
378              
379             B<Default:> 1 = yes, matches are deleted when found
380              
381             B<attribute methods:>
382              
383             =over
384              
385             B<set_match_retention( $bool )>
386              
387             =over
388              
389             B<Description:> Changes the keep_matches attribute setting to the passed $bool
390              
391             =back
392              
393             =back
394              
395             =back
396              
397             =head3 test_buffer_size
398              
399             =over
400              
401             B<Description:> This attribute attempts to mirror L<$Test::Log::Shiras::last_buffer_position
402             |/$Test::Log::Shiras::last_buffer_position>. If you set it upon instantiation of an instance of this
403             class then it will change the global variable too.
404              
405             B<Range:> accepts a positive integer
406              
407             B<Default:> 11 this starts at eleven
408              
409             B<attribute methods:>
410              
411             =over
412              
413             B<change_test_buffer_size( $int )>
414              
415             =over
416              
417             B<Definition:> This will change the maximum test buffer size. If the target buffer size is
418             reduced greater than the current buffer contents the size will not be resolved until the next
419             message is sent to the buffer.
420              
421             =back
422              
423             =back
424              
425             =back
426              
427             =head2 Methods
428              
429             These are not tests!
430              
431             =head3 get_buffer( $report )
432              
433             =over
434              
435             B<Definition:> This will return the full test buffer for a given report. It should be noted
436             that messages are stored with metadata. Active buffers are not an ArrayRef of strings.
437              
438             B<Accepts:> The target $report name
439              
440             B<Returns:> An ArrayRef of HashRefs
441              
442             =back
443              
444             =head2 Tests
445              
446             All tests here are written as methods on an object not exportable functions. As such they
447             are implemented in the following fashion.
448              
449             my $tester = Test::Log::Shiras->new;
450             $tester->match_message( $report, $wanted, $message );
451            
452             =head3 clear_buffer( $report, $message )
453              
454             =over
455              
456             B<Definition:> This test will clear the buffer. It always passes.
457              
458             B<Accepts:> The target $report name string to clear and the $message to append to the test report.
459              
460             B<Returns:> The cleared test name_space
461              
462             =back
463              
464             =head3 has_buffer( $report, $expected, $message )
465              
466             =over
467              
468             B<Definition:> This test checks to see if there is a test buffer for the $report name. It allows
469             for testing a buffer existence whether the buffer is $expected to exist or not.
470              
471             B<Accepts:> The target $report name string to check and whether you $expected to find the buffer or not.
472             It also accepts the $message used for test result reporting.
473              
474             B<Returns:> The tested report buffer name
475              
476             =back
477              
478             =head3 buffer_count( $report, $expected, $message )
479              
480             =over
481              
482             B<Definition:> This test checks a known buffer to see how many records it contains. It will compare that
483             to how many records are $expected. The buffer count will mostly never exceed the L<mandated max
484             |/$Test::Log::Shiras::last_buffer_position> buffer size.
485              
486             B<Accepts:> The target $report name string to check and how many records were $expected in the buffer.
487             It also accepts the $message used for test result reporting.
488              
489             B<Returns:> The tested report buffer name
490              
491             =back
492              
493             =head3 match_message( $report, $test_line, $message )
494              
495             =over
496              
497             B<Definition:> This test checks if a $test_line exists in any of the message elements in the test buffer.
498             The message elements take the following relevant format.
499              
500             $message->{message} =>[ $compare_line1, $compare_line2, etc. ]
501            
502             $compare_line1 and $compare_line2 are the elements tested. If $test_line is a RegexpRef then it will
503             do a regex compare otherwise it does an exact string 'eq' compare. If there is a match the test will
504             splice out the message from the buffer so It won't show up again unless you re-send it to the buffer.
505             This behavior can be changed with the attribute L<keep_matches|/keep_matches>.
506              
507             B<Accepts:> The target $report name string a $test_line [or regex] to check with. It also accepts the
508             $message used for test result reporting.
509              
510             B<Returns:> The tested report buffer name
511              
512             =back
513              
514             =head3 cant_match_message( $report, $test_line, $message )
515              
516             =over
517              
518             B<Definition:> This test checks all messages in a buffer to see if a $test_line exists in any of the
519             message elements. The message elements take the following relevant format.
520              
521             $message->{message} =>[ $compare_line1, $compare_line2, etc. ]
522            
523             $compare_line1 and $compare_line2 are the elements tested. If $test_line is a RegexpRef then it will
524             do a regex compare otherwise it does an exact string 'eq' compare. Even if there is a match the buffer
525             remains un-edited but the test fails.
526              
527             B<Accepts:> The target $report name string a $test_line [or regex] to check with. It also accepts the
528             $message used for test result reporting.
529              
530             B<Returns:> The tested report buffer name
531              
532             =back
533              
534             =head2 GLOBAL VARIABLES
535              
536             =over
537              
538             B<$Test::Log::Shiras::last_buffer_position>
539              
540             =over
541              
542             In order to not have memory issues with long running tests that accumulate buffers without
543             flushing there is a global variable for the max items in the test buffer. The actual test
544             buffer is not stored here but rather in the L<Switchboard|Log::Shiras::Switchboard> in
545             order to leverage the Singleton there. The default value is 11 (Store to 11). So if you
546             want to do a lot of work and then check if a message was processed early on then you need
547             to increase this value (equivalent to max buffer size). Internal to the instance it is
548             best to change the max buffer using the attribute L<test_buffer_size|/test_buffer_size>
549             and it's method.
550              
551             =back
552              
553             =back
554              
555             =head1 SUPPORT
556              
557             =over
558              
559             =item L<github Log-Shiras/issues|https://github.com/jandrew/Log-Shiras/issues>
560              
561             =back
562              
563             =head1 TODO
564              
565             =over
566              
567             B<1.> Nothing yet
568              
569             =back
570              
571             =head1 AUTHOR
572              
573             =over
574              
575             =item Jed Lund
576              
577             =item jandrew@cpan.org
578              
579             =back
580              
581             =head1 COPYRIGHT
582              
583             This program is free software; you can redistribute
584             it and/or modify it under the same terms as Perl itself.
585              
586             The full text of the license can be found in the
587             LICENSE file included with this module.
588              
589             This software is copyrighted (c) 2012, 2016 by Jed Lund.
590              
591             =head1 DEPENDANCIES
592              
593             =over
594              
595             L<version> - 0.77
596              
597             L<5.010|http://perldoc.perl.org/perl5100delta.html> (for use of
598             L<defined or|http://perldoc.perl.org/perlop.html#Logical-Defined-Or> //)
599              
600             L<utf8>
601              
602             L<Moose>
603              
604             L<MooseX::StrictConstructor>
605              
606             L<MooseX::HasDefaults::RO>
607              
608             L<Test2::API> - context
609              
610             L<MooseX::Types::Moose> - RegexpRef Bool ArrayRef
611              
612             L<Log::Shiras::Switchboard> - 0.029
613              
614             L<Log::Shiras::Types>
615              
616             =back
617              
618             =head1 SEE ALSO
619              
620             =over
621              
622             L<Log::Log4perl::Appender::TestBuffer>
623              
624             L<Log::Log4perl::Appender::TestArrayBuffer>
625              
626             =back
627              
628             =cut
629              
630             #################### <where> - main pod documentation end ###################