[Bps-public-commit] r11273 - in SVN-PropDB: . doc t

jesse at bestpractical.com jesse at bestpractical.com
Sun Mar 30 16:48:30 EDT 2008


Author: jesse
Date: Sun Mar 30 16:48:29 2008
New Revision: 11273

Added:
   SVN-PropDB/lib/Prophet/Test.pm
Modified:
   SVN-PropDB/   (props changed)
   SVN-PropDB/doc/glossary
   SVN-PropDB/t/cli.t

Log:
 r28796 at 68-247-16-135:  jesse | 2008-03-30 10:08:16 -1000
 checkpoint


Modified: SVN-PropDB/doc/glossary
==============================================================================
--- SVN-PropDB/doc/glossary	(original)
+++ SVN-PropDB/doc/glossary	Sun Mar 30 16:48:29 2008
@@ -12,25 +12,26 @@
    8. The network is homogeneous.
 
 
-nihao
-
 Glossary:
 
+=head1 Terms
+
 
-Database
+
+=head2 Database
     A term to describe a uniquely identified set of object types and records sharing a single 'base' revision and Replica identifier
     A database contains multiple Records
    
     Has one: uuid
 
 
-Replica
+=head2 Replica
     An instance of a database. Replicas are expected to contain all Changesets from any other replica they have been synchronized with, but those Changesets are not guaranteed to be in the same sequence on each replica
 
 
     Has one: uuid
 
-Changeset
+=head2 Changeset
     A changeset contains "old" and "new" versions of a set of database "Records", they can be of any Record Type.
     
     Has one: source_uuid, sequence_no
@@ -38,10 +39,10 @@
 
 
 
-Change
+=head2 Change
     An entry in a changeset. Contains all the updates to a given record for this changeset
    
-Record
+=head2 Record
     A Record is composed of zero or more Attributes and a universally unique identifier. Each record is categorized into a Record Type.
        
 
@@ -50,7 +51,7 @@
 
 
 
-Record Type 
+=head2 Record Type 
     A Record Type is a category or "bucket" for zero or more records applications may define specific behaviours for Records of a certain Record Type, but Prophet does no more than to tag Records with a Record Type.
 Record Types are uniquely identified with a textual name and a UUID
     
@@ -59,13 +60,13 @@
 
 
 
-Attribute
+=head2 Attribute
     A key-value pair on a Record.    
 
     Has one: key, value
 
 
-Conflict
+=head2 Conflict
     A Conflict occurs when a Changeset is being applied and the current state of a Replica meets any of the following criteria:
 
         * The Replica already contains a node marked as "created" in the changeset
@@ -73,5 +74,21 @@
         * The Replica doesn't contain a node marked as "updated" in the changeset
         * The Replica contains a node marked as "updated" in the changeset, but the current state of the properties on the node does not match the "old" state of the node in the changeset.
     
-Resolution
+=head2 Resolution
     When the local Replica 
+
+
+
+=head1 NON-TERMS
+
+=head2 Node
+
+Too many things get called nodes
+
+=head2 revision
+
+Revision is a term from version control. the backing store may describe it but it's not a Prophet term
+
+=head2 
+
+

Added: SVN-PropDB/lib/Prophet/Test.pm
==============================================================================
--- (empty file)
+++ SVN-PropDB/lib/Prophet/Test.pm	Sun Mar 30 16:48:29 2008
@@ -0,0 +1,85 @@
+package Prophet::Test;
+
+use base qw/Test::More Exporter/;
+our @EXPORT = qw/as_alice as_bob as_charlie as_david/;
+
+use File::Temp qw/tempdir/;
+use Path::Class 'dir';
+
+our $REPO_BASE = File::Temp::tempdir();
+
+sub import_extra {
+    my $class = shift;
+    my $args  = shift;
+
+    $class->setup($args);
+    Test::More->export_to_level(2);
+
+    # Now, clobber Test::Builder::plan (if we got given a plan) so we
+    # don't try to spit one out *again* later
+    if ($class->builder->has_plan) {
+        no warnings 'redefine';
+        *Test::Builder::plan = sub {};
+    }
+}
+
+=head2 repo_path_for $USERNAME
+
+Returns a path on disk for where $USERNAME's replica is stored
+
+=cut
+
+sub repo_path_for {
+my $username = shift;
+ return dir($REPO_BASE)->subdir($username);
+}
+
+
+=head2 repo_uri_for $USERNAME
+
+Returns a subversion file:// URI for $USERNAME'S replica
+
+=cut
+
+use constant IS_WIN32 => ($^O eq 'MSWin32');
+
+sub repo_uri_for {
+    my $username = shift;    
+    
+    my $path = repo_path_for($username);
+    $path =~ s{^|\\}{/}g if IS_WIN32;
+
+    return 'file://'.$path;
+}
+
+=head2 as_user USERNAME CODEREF
+
+Run this code block as USERNAME.  This routine sets up the %ENV hash so that when we go looking for a repository, we get the user's repo.
+
+=cut
+
+sub as_user {
+  my $username = shift;
+  my $coderef = shift;
+
+  local $ENV{'PROPHET_REPO'} = repo_path_for($username);
+ $coderef->();
+}
+
+
+
+=head2 as_alice CODE, as_bob CODE, as_charlie CODE, as_david CODE
+
+Runs CODE as alice, bob, charlie or david
+
+
+=cut
+
+as_alice (&) { as_user( alice => shift) }
+as_bob (&){ as_user( bob => shift) }
+as_charlie(&) { as_user( charlie => shift) }
+as_david(&) { as_user( david => shift) }
+
+
+
+1;

Modified: SVN-PropDB/t/cli.t
==============================================================================
--- SVN-PropDB/t/cli.t	(original)
+++ SVN-PropDB/t/cli.t	Sun Mar 30 16:48:29 2008
@@ -3,12 +3,11 @@
 use warnings;
 use strict;
 
-use Test::More qw/no_plan/;
+use Prophet::Test tests => 3;
 
-$ENV{'PROPHET_REPO'} = '/tmp/prophet';
-
-
-ok(`bin/prophet-node-create --type Bug --status new` );
+as_alice {
+    ok(`bin/prophet-node-create --type Bug --status new` );
+}
 
 # create 1 node
 # update the node



More information about the Bps-public-commit mailing list