[Bps-public-commit] r16246 - sd/trunk/t

ruz at bestpractical.com ruz at bestpractical.com
Wed Oct 8 14:08:32 EDT 2008


Author: ruz
Date: Wed Oct  8 14:08:31 2008
New Revision: 16246

Added:
   sd/trunk/t/sd-hm-tag.t

Log:
* add tests for syncing things with particular props between SD and HM

Added: sd/trunk/t/sd-hm-tag.t
==============================================================================
--- (empty file)
+++ sd/trunk/t/sd-hm-tag.t	Wed Oct  8 14:08:31 2008
@@ -0,0 +1,109 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use Prophet::Test;
+use App::SD::Test;
+
+BEGIN {
+    if ( $ENV{'JIFTY_APP_ROOT'} ) {
+        plan tests => 12;
+        require File::Temp;
+        $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} = File::Temp::tempdir( CLEANUP => 0 ) . '/_svb';
+        diag $ENV{'PROPHET_REPO'};
+        eval "use Jifty";
+        push @INC, File::Spec->catdir( Jifty::Util->app_root, "lib" );
+    } else {
+        plan skip_all => "You must define a JIFTY_APP_ROOT environment variable which points to your hiveminder source tree";
+    }
+}
+
+eval 'use BTDT::Test; 1;' or die "$@";
+
+my $server = BTDT::Test->make_server;
+my $URL    = $server->started_ok;
+
+$URL =~ s|http://|http://onlooker\@example.com:something@|;
+
+ok( 1, "Loaded the test script" );
+my $root = BTDT::CurrentUser->superuser;
+my $as_root = BTDT::Model::User->new( current_user => $root );
+$as_root->load_by_cols( email => 'onlooker at example.com' );
+my ( $val, $msg ) = $as_root->set_accepted_eula_version( Jifty->config->app('EULAVersion') );
+ok( $val, $msg );
+my $GOODUSER = BTDT::CurrentUser->new( email => 'onlooker at example.com' );
+$GOODUSER->user_object->set_accepted_eula_version( Jifty->config->app('EULAVersion') );
+
+my $task = BTDT::Model::Task->new( current_user => $GOODUSER );
+$task->create(
+    summary     => "Fly Man",
+    description => '',
+    tags        => 'mytag'
+);
+diag $task->id;
+
+{
+    my $task = BTDT::Model::Task->new( current_user => $GOODUSER );
+    $task->create(
+        summary     => "without the tag",
+        description => '',
+        tags        => 'notag'
+    );
+    diag $task->id;
+}
+
+my ( $ret, $out, $err );
+
+my $sd_hm_url = "hm:$URL|tag=mytag";
+eval { ( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_hm_url ] ) };
+like($out, qr/one changeset/, "only one change");
+
+my ($flyman_uuid, $flyman_id );
+{
+    run_output_matches( 'sd', [ 'ticket', 'list', '--regex', '.' ], [qr/(.*?)(?{ $flyman_uuid = $1 }) Fly Man (.*)/] );
+    ( $ret, $out, $err ) = run_script( 'sd', [ 'ticket', 'show', '--batch', '--id', $flyman_uuid ] );
+    if ($out =~ /^id: (\d+) /m) {
+        $flyman_id = $1;
+    }
+}
+
+{
+    $task->set_summary('Crash Man');
+    ( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_hm_url ] );
+    run_output_matches_unordered( 'sd', [ 'ticket', 'list', '--regex', '.' ], ["$flyman_uuid Crash Man (no status)"] );
+}
+
+
+my ($yatta_id, $yatta_uuid) = create_ticket_ok( '--summary', 'YATTA', '--status', 'new' );
+diag $yatta_uuid;
+
+run_output_matches_unordered(
+    'sd',
+    [ 'ticket', 'list', '--regex', '.' ],
+    [ "$yatta_id YATTA new", "$flyman_id Crash Man (no status)" ]
+);
+
+{
+    ( $ret, $out, $err ) = run_script( 'sd', [ 'push','--to', $sd_hm_url ] );
+    diag $err;
+    ok( $task->load_by_cols( summary => 'YATTA' ), "loaded HM task" );
+    like( $task->tags, qr/\bmytag\b/, "has tag" );
+}
+
+{
+    ( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from',$sd_hm_url ] );
+    run_output_matches_unordered(
+        'sd',
+        [ 'ticket',                     'list', '--regex', '.' ],
+        [ "$yatta_id YATTA new", "$flyman_id Crash Man (no status)" ]
+    );
+}
+
+{
+    $task->set_summary('KILL');
+    ( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_hm_url ] );
+    run_output_matches_unordered(
+        'sd',
+        [ 'ticket',                    'list', '--regex', '.' ],
+        [ "$yatta_id KILL new", "$flyman_id Crash Man (no status)" ]
+    );
+}



More information about the Bps-public-commit mailing list