[Bps-public-commit] Prophet - A disconnected, replicated p2p database branch, master, updated. 2ca749db17fe0f8271f8ef01e09ca8655fc3bb2e

spang at bestpractical.com spang at bestpractical.com
Wed Jan 28 07:23:10 EST 2009


The branch, master has been updated
       via  2ca749db17fe0f8271f8ef01e09ca8655fc3bb2e (commit)
      from  dcb139e8de9dec48d34ba50b4e57da9022a5386f (commit)

Summary of changes:
 t/lib/TestApp/Bug.pm          |   11 ++++++---
 t/lib/TestApp/BugCatcher.pm   |   12 +++++++++++
 t/lib/TestApp/Bugs.pm         |    9 ++++++++
 t/lib/TestApp/ButterflyNet.pm |    9 ++++++++
 t/references.t                |   43 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 80 insertions(+), 4 deletions(-)
 create mode 100644 t/lib/TestApp/BugCatcher.pm
 create mode 100644 t/lib/TestApp/Bugs.pm
 create mode 100644 t/lib/TestApp/ButterflyNet.pm
 create mode 100644 t/references.t

- Log -----------------------------------------------------------------
commit 2ca749db17fe0f8271f8ef01e09ca8655fc3bb2e
Author: Christine Spang <spang at bestpractical.com>
Date:   Wed Jan 28 14:01:48 2009 +0200

    test coverage for references... maybe now we won't accidentally break
    them again

diff --git a/t/lib/TestApp/Bug.pm b/t/lib/TestApp/Bug.pm
index 95c1a2a..1b449bf 100644
--- a/t/lib/TestApp/Bug.pm
+++ b/t/lib/TestApp/Bug.pm
@@ -1,12 +1,12 @@
-use warnings;
-use strict;
-
 package TestApp::Bug;
 use Moose;
 extends 'Prophet::Record';
 
+has type => ( default => 'bug' );
+
+use constant collection_class => 'TestApp::Bugs';
 
-sub new { shift->SUPER::new( @_, type => 'bug' ) }
+__PACKAGE__->register_reference( bugcatcher => 'TestApp::BugCatcher' );
 
 sub validate_prop_name {
     my $self = shift;
@@ -26,4 +26,7 @@ sub canonicalize_prop_email {
 
 sub default_prop_status { 'new' }
 
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
 1;
diff --git a/t/lib/TestApp/BugCatcher.pm b/t/lib/TestApp/BugCatcher.pm
new file mode 100644
index 0000000..51e874e
--- /dev/null
+++ b/t/lib/TestApp/BugCatcher.pm
@@ -0,0 +1,12 @@
+package TestApp::BugCatcher;
+use Moose;
+extends 'Prophet::Record';
+
+has type => ( default => 'bugcatcher' );
+
+__PACKAGE__->register_reference( bugs => 'TestApp::Bugs', by => 'bugcatcher');
+__PACKAGE__->register_reference( net => 'TestApp::ButterflyNet' );
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+1;
diff --git a/t/lib/TestApp/Bugs.pm b/t/lib/TestApp/Bugs.pm
new file mode 100644
index 0000000..b18dc8e
--- /dev/null
+++ b/t/lib/TestApp/Bugs.pm
@@ -0,0 +1,9 @@
+package TestApp::Bugs;
+use Moose;
+extends 'Prophet::Collection';
+
+use constant record_class => 'TestApp::Bug';
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+1;
diff --git a/t/lib/TestApp/ButterflyNet.pm b/t/lib/TestApp/ButterflyNet.pm
new file mode 100644
index 0000000..d86c58d
--- /dev/null
+++ b/t/lib/TestApp/ButterflyNet.pm
@@ -0,0 +1,9 @@
+package TestApp::ButterflyNet;
+use Moose;
+extends 'Prophet::Record';
+
+has type => ( default => 'net' );
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+1;
diff --git a/t/references.t b/t/references.t
new file mode 100644
index 0000000..7a379aa
--- /dev/null
+++ b/t/references.t
@@ -0,0 +1,43 @@
+use warnings;
+use strict;
+use Test::More tests => 8;
+use lib 't/lib';
+
+use File::Temp qw'tempdir';
+
+# test coverage for Prophet::Record references (subs register_reference,
+# register_collection_reference, and register_record_reference)
+
+use_ok('Prophet::CLI');
+$ENV{'PROPHET_REPO'} = tempdir( CLEANUP => ! $ENV{PROPHET_DEBUG}  ) . '/repo-' . $$;
+
+my $cli = Prophet::CLI->new();
+my $cxn = $cli->handle;
+my $app = $cli->app_handle;
+isa_ok( $cxn, 'Prophet::Replica', "Got the cxn" );
+
+$cxn->initialize;
+
+use_ok('TestApp::ButterflyNet');
+my $net = TestApp::ButterflyNet->new( handle => $cxn );
+$net->create( props => { catches => 'butterflies' } );
+
+use_ok('TestApp::BugCatcher');
+my $bugcatcher = TestApp::BugCatcher->new( app_handle => $app, handle => $cxn );
+$bugcatcher->create( props => { net => $net->uuid, name => 'Larry' } );
+
+use_ok('TestApp::Bug');
+my $monarch = TestApp::Bug->new( handle => $cxn );
+$monarch->create( props => { bugcatcher => $bugcatcher->uuid, species =>
+        'monarch' } );
+my $viceroy = TestApp::Bug->new( handle => $cxn );
+$viceroy->create( props => { bugcatcher => $bugcatcher->uuid, species =>
+        'viceroy' } );
+
+# test collection reference
+my @bugs = @{$bugcatcher->bugs};
+is($bugs[0]->uuid, $monarch->uuid, "monarch butterfly uuids match");
+is($bugs[1]->uuid, $viceroy->uuid, "viceroy butterfly uuids match");
+
+# test record reference
+is($bugcatcher->net->uuid, $net->uuid);

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list