Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add TB2::History::NoEventStorage which TB2::History will use.

For #198
  • Loading branch information...
commit 97d3d48a1b3ccc46486deba35371d16624745b71 1 parent 9626992
@schwern schwern authored
Showing with 94 additions and 0 deletions.
  1. +69 −0 lib/TB2/History/NoEventStorage.pm
  2. +25 −0 t/History/NoEventStorage.t
View
69 lib/TB2/History/NoEventStorage.pm
@@ -0,0 +1,69 @@
+package TB2::History::NoEventStorage;
+
+use Carp;
+use TB2::Mouse;
+
+
+=head1 NAME
+
+TB2::History::NoEventStorage - Throw out all events
+
+=head1 SYNOPSIS
+
+ my $storage = TB2::History::NoEventStorage->new;
+
+ # Immediately discarded.
+ $storage->event_push($event);
+
+ # Trying to look at the events causes an exception.
+ my $events = $storage->events;
+ my $results = $storage->results;
+
+=head1 DESCRIPTION
+
+This object throws out all its input events and stores nothing.
+
+This implements the L<TB2::History::EventStorage> interface. It
+exists so that L<TB2::History> can be configured to not store events
+and thus not grow in memory as the tests run.
+
+=head2 Methods
+
+The interface is the same as L<TB2::History::EventStorage> with the
+following exceptions.
+
+=head3 events
+
+=head3 results
+
+If called, they will both throw an exception.
+
+=cut
+
+sub events {
+ croak "Events are not stored";
+}
+
+sub results {
+ croak "Results are not stored";
+}
+
+
+=head3 events_push
+
+Calls to this method will be ignored.
+
+=cut
+
+sub events_push {}
+
+
+=head1 SEE ALSO
+
+L<TB2::History::EventStorage> is like NoEventStorage but it actually
+stores events.
+
+=cut
+
+
+1;
View
25 t/History/NoEventStorage.t
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+BEGIN { require "t/test.pl" }
+
+use TB2::Events;
+
+my $CLASS = 'TB2::History::NoEventStorage';
+require_ok $CLASS;
+
+note "Event and result storage"; {
+ my $storage = $CLASS->new;
+
+ ok !eval { is_deeply $storage->events; 1 };
+ ok !eval { is_deeply $storage->results; 1 };
+
+ $storage->events_push( TB2::Event::Comment->new( comment => "No 1" ) );
+
+ ok !eval { is_deeply $storage->events; 1 };
+ ok !eval { is_deeply $storage->results; 1 };
+}
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.