File Coverage

lib/Log/Shiras/Test2.pm
Criterion Covered Total %
statement 106 138 76.8
branch 17 32 53.1
condition 10 17 58.8
subroutine 21 23 91.3
pod 6 7 85.7
total 160 217 73.7


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