[Bps-public-commit] r14789 - Prophet/branches/creator/t

sartak at bestpractical.com sartak at bestpractical.com
Tue Aug 5 13:04:27 EDT 2008


Author: sartak
Date: Tue Aug  5 13:04:27 2008
New Revision: 14789

Modified:
   Prophet/branches/creator/t/publish-pull.t

Log:
Ensure that when we pull from a published repo, the creator is correct

Modified: Prophet/branches/creator/t/publish-pull.t
==============================================================================
--- Prophet/branches/creator/t/publish-pull.t	(original)
+++ Prophet/branches/creator/t/publish-pull.t	Tue Aug  5 13:04:27 2008
@@ -1,10 +1,11 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Prophet::Test tests => 13;
+use Prophet::Test tests => 22;
 use Test::Exception;
 use File::Temp 'tempdir';
 use Path::Class;
+use Params::Validate;
 
 my $alice_published = tempdir(CLEANUP => 1);
 
@@ -50,3 +51,77 @@
 
 is(database_uuid_for('alice'), database_uuid_for('david'), "pull propagated the database uuid properly");
 isnt(replica_uuid_for('alice'), replica_uuid_for('david'), "pull created a new replica uuid");
+
+for my $user ('alice', 'bob', 'charlie', 'david') {
+    my $replica = Prophet::Replica->new({ url => repo_uri_for($user) });
+    my $changesets = $replica->fetch_changesets(after => 0);
+
+    diag "Verifying $user\'s first changeset";
+    changeset_ok(
+        changeset   => $changesets->[0],
+        user        => $user,
+        record_type => 'Bug',
+        sequence_no => 1,
+        merge       => $user ne 'alice',
+    );
+
+    diag "Verifying $user\'s second changeset";
+    changeset_ok(
+        changeset   => $changesets->[1],
+        user        => $user,
+        record_type => 'Pullall',
+        sequence_no => 2,
+        merge       => $user ne 'alice',
+    );
+}
+
+sub changeset_ok {
+    local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+    my %args = validate(@_, {
+        changeset   => 1,
+        user        => 1,
+        sequence_no => 1,
+        record_type => 1,
+        merge       => 1,
+    });
+
+    my $changeset = $args{changeset};
+
+    is_deeply($changeset, bless {
+        creator              => 'alice',
+        created              => $changeset->created,
+        is_resolution        => undef,
+        is_nullification     => undef,
+        sequence_no          => $args{sequence_no},,
+        source_uuid          => replica_uuid_for($args{user}),
+        original_sequence_no => $args{sequence_no},
+        original_source_uuid => replica_uuid_for('alice'),
+        changes              => [
+            bless({
+                change_type  => 'add_file',
+                record_type  => $args{record_type},
+                record_uuid  => $changeset->changes->[0]->record_uuid,
+                prop_changes => [
+                    bless({
+                        name      => 'status',
+                        old_value => undef,
+                        new_value => 'new',
+                    }, 'Prophet::PropChange'),
+                    bless {
+                        name      => 'from',
+                        old_value => undef,
+                        new_value => 'alice',
+                    }, 'Prophet::PropChange',
+                ],
+            }, 'Prophet::Change'),
+
+            # need to account for the merge ticket except in the original
+            # replica
+            $args{merge}
+            ? $changeset->changes->[1]
+            : ()
+        ],
+    }, 'Prophet::ChangeSet');
+}
+



More information about the Bps-public-commit mailing list