[Bps-public-commit] r11575 - SVN-PropDB/t
clkao at bestpractical.com
clkao at bestpractical.com
Sun Apr 6 00:01:15 EDT 2008
Author: clkao
Date: Sun Apr 6 00:01:13 2008
New Revision: 11575
Added:
SVN-PropDB/t/sd-rt-hm.t
Log:
basic tests for rt/hm sync between rt and hm
Added: SVN-PropDB/t/sd-rt-hm.t
==============================================================================
--- (empty file)
+++ SVN-PropDB/t/sd-rt-hm.t Sun Apr 6 00:01:13 2008
@@ -0,0 +1,207 @@
+#!/usr/bin/perl -w
+
+# to run:
+#
+# RT_DBA_USER=root RT_DBA_PASSWORD= prove -lv -I/Users/clkao/work/bps/rt-3.7/lib t/sd-rt.t
+use strict;
+
+use Test::More;
+eval 'use RT::Test; 1'
+ or plan skip_all => 'requires 3.7 to run tests.'.$@;
+
+BEGIN {
+ unless ($ENV{'JIFTY_APP_ROOT'}) {
+ die "You must define a JIFTY_APP_ROOT environment variable which points to your hiveminder source tree";
+ }
+ require File::Temp;
+ use Jifty;
+ push @INC, File::Spec->catdir(Jifty::Util->app_root, "lib");
+}
+
+
+no warnings 'once';
+
+RT::Handle->InsertData($RT::EtcPath.'/initialdata');
+
+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@|;
+my $sd_hm_url = "hm:$URL";
+
+ok(1, "Loaded the test script");
+
+# setup for rt
+use Prophet::Test tests => 7;
+
+my ($url, $m) = RT::Test->started_ok;
+diag $url;
+
+use RT::Client::REST;
+use RT::Client::REST::Ticket;
+my $rt = RT::Client::REST->new( server => $url );
+$rt->login( username => 'root', password => 'password' );
+
+$url =~ s|http://|http://root:password@|;
+warn $url;
+my $sd_rt_url = "rt:$url|General|Status!='resolved'";
+
+my $ticket = RT::Client::REST::Ticket->new(
+ rt => $rt,
+ queue => 'General',
+ status => 'new',
+ subject => 'Fly Man',
+ )->store(text => "Ticket Comment");
+
+# setup for hm
+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 => "YATTA",
+ description => '',
+);
+
+
+my ($yatta_uuid, $flyman_uuid);
+my ($ret, $out, $err);
+# now the tests, bob syncs with rt, alice syncs with hm
+as_alice {
+ local $ENV{SVB_REPO} = $ENV{'PROPHET_REPO'};
+ ($ret, $out, $err) = run_script('sd', ['pull', $sd_hm_url]);
+ warn $err;
+ run_output_matches('sd', ['ticket', '--list', '--regex', '.'], [qr/(.*?)(?{ $flyman_uuid = $1 }) YATTA .*/]);
+};
+
+as_bob {
+ local $ENV{SVB_REPO} = $ENV{'PROPHET_REPO'};
+ run_output_matches('sd', ['ticket', '--list', '--regex', '.'], []);
+ ($ret, $out, $err) = run_script('sd', ['pull', $sd_rt_url]);
+ warn $err;
+ run_output_matches('sd', ['ticket', '--list', '--regex', '.'], [qr/(.*?)(?{ $flyman_uuid = $1 }) Fly Man new/]);
+
+
+ ($ret, $out, $err) = run_script('sd', ['pull', repo_uri_for('alice')]);
+ ($ret, $out, $err) = run_script('sd', ['ticket', '--list', '--regex', '.']);
+ warn $out;
+ warn $err;
+
+};
+
+
+
+__END__
+
+
+
+use Test::More;
+
+my ($url, $m) = RT::Test->started_ok;
+
+use RT::Client::REST;
+use RT::Client::REST::Ticket;
+my $rt = RT::Client::REST->new( server => $url );
+$rt->login( username => 'root', password => 'password' );
+
+$url =~ s|http://|http://root:password@|;
+warn $url;
+my $sd_rt_url = "rt:$url|General|Status!='resolved'";
+
+my $ticket = RT::Client::REST::Ticket->new(
+ rt => $rt,
+ queue => 'General',
+ status => 'new',
+ subject => 'Fly Man',
+ )->store(text => "Ticket Comment");
+
+diag $ticket->id;
+my ($ret, $out, $err);
+($ret, $out, $err) = run_script('sd', ['pull', $sd_rt_url]);
+warn $err;
+my ($yatta_uuid, $flyman_uuid);
+run_output_matches('sd', ['ticket', '--list', '--regex', '.'], [qr/(.*?)(?{ $flyman_uuid = $1 }) Fly Man new/]);
+
+
+RT::Client::REST::Ticket->new(
+ rt => $rt,
+ id => $ticket->id,
+ status => 'open',
+ )->store();
+
+($ret, $out, $err) = run_script('sd', ['pull', $sd_rt_url]);
+
+run_output_matches('sd', ['ticket', '--list', '--regex', '.'], ["$flyman_uuid Fly Man open"]);
+
+# create from sd and push
+
+run_output_matches('sd', ['ticket', '--create', '--summary', 'YATTA', '--status', 'new'], [qr/Created ticket (.*)(?{ $yatta_uuid = $1 })/]);
+
+diag $yatta_uuid;
+
+run_output_matches('sd', ['ticket', '--list', '--regex', '.'],
+ [ sort
+ "$yatta_uuid YATTA new",
+ "$flyman_uuid Fly Man open",
+ ]);
+
+($ret, $out, $err) = run_script('sd', ['push', $sd_rt_url]);
+diag $err;
+my @tix = $rt->search(
+ type => 'ticket',
+ query => "Subject='YATTA'"
+ );
+
+ok(scalar @tix, 'YATTA pushed');
+
+($ret, $out, $err) = run_script('sd', ['pull', $sd_rt_url]);
+
+run_output_matches('sd', ['ticket', '--list', '--regex', '.'],
+ [ sort
+ "$yatta_uuid YATTA new",
+ "$flyman_uuid Fly Man open",
+ ]);
+
+RT::Client::REST::Ticket->new(
+ rt => $rt,
+ id => $ticket->id,
+ status => 'stalled',
+ )->store();
+
+($ret, $out, $err) = run_script('sd', ['pull', $sd_rt_url]);
+
+run_output_matches('sd', ['ticket', '--list', '--regex', '.'],
+ [ sort
+ "$yatta_uuid YATTA new",
+ "$flyman_uuid Fly Man stalled",
+ ]);
+
+RT::Client::REST::Ticket->new(
+ rt => $rt,
+ id => $tix[0],
+ status => 'open',
+ )->store();
+
+warn "===> bad pull";
+($ret, $out, $err) = run_script('sd', ['pull', $sd_rt_url]);
+diag $err;
+run_output_matches('sd', ['ticket', '--list', '--regex', '.'],
+ [ sort
+ "$yatta_uuid YATTA open",
+ "$flyman_uuid Fly Man stalled",
+ ]);
+
+#diag $uuid;
+
+1;
+
+
+
+
More information about the Bps-public-commit
mailing list