Permalink
Browse files

Add Metabase::Test::Archive::Null for testing

  • Loading branch information...
1 parent e6f5aa6 commit 3c7b7078c7e66d5909270073abfb6b0e0c94d585 @xdg xdg committed Sep 14, 2011
Showing with 63 additions and 0 deletions.
  1. +63 −0 lib/Metabase/Test/Archive/Null.pm
View
63 lib/Metabase/Test/Archive/Null.pm
@@ -0,0 +1,63 @@
+use 5.006;
+use strict;
+use warnings;
+
+package Metabase::Test::Archive::Null;
+# ABSTRACT: Metabase storage that discards all data
+# VERSION
+
+use Moose;
+
+use Carp ();
+use Data::Stream::Bulk::Nil;
+
+with 'Metabase::Archive';
+
+sub initialize { }
+
+# given fact, discard it and return guid
+sub store {
+ my ($self, $fact_struct) = @_;
+
+ my $guid = $fact_struct->{metadata}{core}{guid};
+ unless ( $guid ) {
+ Carp::confess "Can't store: no GUID set for fact\n";
+ }
+
+ # do nothing except return
+ return $guid;
+}
+
+# we discard, so can't ever extract
+sub extract {
+ die "unimplemented";
+}
+
+# does nothing
+sub delete {
+ my ($self, $guid) = @_;
+ return $guid;
+}
+
+# we have nothing to return
+sub iterator {
+ return Data::Stream::Bulk::Nil->new;
+}
+
+1;
+
+__END__
+
+=for Pod::Coverage
+ store extract delete iterator initialize
+
+=head1 SYNOPSIS
+
+ require Metabase::Test::Archive::Null;
+ $archive = Metabase::Test::Archive::Null->new;
+
+=head1 DESCRIPTION
+
+Discards all facts to be stored. For testing only, obviously.
+
+=cut

0 comments on commit 3c7b707

Please sign in to comment.