[Bps-public-commit] r16902 - sd/trunk/t/sd-rt
jesse at bestpractical.com
jesse at bestpractical.com
Tue Nov 18 18:05:17 EST 2008
Author: jesse
Date: Tue Nov 18 18:05:17 2008
New Revision: 16902
Modified:
sd/trunk/t/sd-rt/basic.t
Log:
perltidy;
Modified: sd/trunk/t/sd-rt/basic.t
==============================================================================
--- sd/trunk/t/sd-rt/basic.t (original)
+++ sd/trunk/t/sd-rt/basic.t Tue Nov 18 18:05:17 2008
@@ -9,7 +9,7 @@
use Path::Class;
BEGIN {
- unless (eval 'use RT::Test; 1') {
+ unless ( eval 'use RT::Test; 1' ) {
diag $@ if $ENV{'TEST_VERBOSE'};
plan skip_all => 'requires RT 3.8 or newer to run tests.';
}
@@ -25,14 +25,13 @@
BEGIN {
require File::Temp;
- $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'} = File::Temp::tempdir( CLEANUP => 0 ) . '/_svb';
- diag "export SD_REPO=".$ENV{'PROPHET_REPO'} ."\n";
+ $ENV{'PROPHET_REPO'} = $ENV{'SD_REPO'}
+ = File::Temp::tempdir( CLEANUP => 0 ) . '/_svb';
+ diag "export SD_REPO=" . $ENV{'PROPHET_REPO'} . "\n";
}
-
my $IMAGE_FILE = qw|t/data/bplogo.gif|;
-
my ( $url, $m ) = RT::Test->started_ok;
use RT::Client::REST;
@@ -51,20 +50,27 @@
)->store( text => "Ticket Comment" );
my ( $ret, $out, $err );
-( $ret, $out, $err ) = run_script( 'sd', [ 'clone', '--from', $sd_rt_url ] );
+( $ret, $out, $err ) = run_script( 'sd', [ 'clone', '--from', $sd_rt_url ] );
my ( $yatta_id, $flyman_id );
-run_output_matches( 'sd', [ 'ticket', 'list', '--regex', '.' ],
- [qr/(.*?)(?{ $flyman_id = $1 }) Fly Man new/] );
+run_output_matches(
+ 'sd',
+ [ 'ticket', 'list', '--regex', '.' ],
+ [qr/(.*?)(?{ $flyman_id = $1 }) Fly Man new/]
+);
RT::Client::REST::Ticket->new(
rt => $rt,
id => $ticket->id,
status => 'open',
)->store();
-run_script( 'sd', [ 'init']);
+run_script( 'sd', ['init'] );
( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
-run_output_matches( 'sd', [ 'ticket', 'list', '--regex', '.' ], ["$flyman_id Fly Man open"] );
+run_output_matches(
+ 'sd',
+ [ 'ticket', 'list', '--regex', '.' ],
+ ["$flyman_id Fly Man open"]
+);
# create from sd and push
@@ -74,11 +80,15 @@
[qr/Created ticket (\d+)(?{ $yatta_id = $1 })/]
);
-run_output_matches_unordered( 'sd', [ 'ticket', 'list', '--regex', '.' ], [sort "$yatta_id YATTA new", "$flyman_id Fly Man open" ]);
+run_output_matches_unordered(
+ 'sd',
+ [ 'ticket', 'list', '--regex', '.' ],
+ [ sort "$yatta_id YATTA new", "$flyman_id Fly Man open" ]
+);
( $ret, $out, $err ) = run_script( 'sd', [ 'push', '--to', $sd_rt_url ] );
-diag ($out);
-diag ($err);
+diag($out);
+diag($err);
my @tix = $rt->search(
type => 'ticket',
query => "Subject='YATTA'"
@@ -86,16 +96,12 @@
ok( scalar @tix, 'YATTA pushed' );
-
-
-
-
( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
run_output_matches_unordered(
'sd',
- [ 'ticket', 'list', '--regex', '.' ],
- [ "$yatta_id YATTA new", "$flyman_id Fly Man open", ]
+ [ 'ticket', 'list', '--regex', '.' ],
+ [ "$yatta_id YATTA new", "$flyman_id Fly Man open", ]
);
RT::Client::REST::Ticket->new(
@@ -108,7 +114,7 @@
run_output_matches_unordered(
'sd',
- [ 'ticket', 'list', '--regex', '.' ],
+ [ 'ticket', 'list', '--regex', '.' ],
[ "$yatta_id YATTA new", "$flyman_id Fly Man stalled", ]
);
@@ -118,102 +124,117 @@
status => 'open',
)->store();
-diag( "===> bad pull");
+diag("===> bad pull");
( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
run_output_matches_unordered(
'sd',
- [ 'ticket', 'list', '--regex', '.' ],
+ [ 'ticket', 'list', '--regex', '.' ],
[ "$yatta_id YATTA open", "$flyman_id Fly Man stalled", ]
);
-
my $tick = RT::Client::REST::Ticket->new(
rt => $rt,
- id => $tix[0])->retrieve;
-
-my ($val,$msg) = $tick->comment( message => 'this is a comment', attachments => [$IMAGE_FILE]);
+ id => $tix[0]
+)->retrieve;
+my ( $val, $msg ) = $tick->comment(
+ message => 'this is a comment',
+ attachments => [$IMAGE_FILE]
+);
-my @attachments = get_rt_ticket_attachments($tix[0]);
+my @attachments = get_rt_ticket_attachments( $tix[0] );
-is (scalar @attachments, 1, "Found our one attachment");
+is( scalar @attachments, 1, "Found our one attachment" );
-
( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
run_output_matches_unordered(
'sd',
- [ 'ticket', 'list', '--regex', '.' ],
+ [ 'ticket', 'list', '--regex', '.' ],
[ "$yatta_id YATTA open", "$flyman_id Fly Man stalled", ]
);
diag("check to see if YATTA has an attachment");
-
my $rt_attach_id;
-run_output_matches( sd => [qw/ticket attachment list --id/, $yatta_id], [qr/(.*?)(?{ $rt_attach_id = $1 }) bplogo.gif image\/gif/] );
+run_output_matches(
+ sd => [ qw/ticket attachment list --id/, $yatta_id ],
+ [qr/(.*?)(?{ $rt_attach_id = $1 }) bplogo.gif image\/gif/]
+);
ok($rt_attach_id);
-diag("Check to see if YATTA's attachment is binary-identical to the original one");
+diag(
+ "Check to see if YATTA's attachment is binary-identical to the original one"
+);
my $image_data = file($IMAGE_FILE)->slurp;
-my ($contentret, $stdout, $stderr) = run_script('sd', [qw/attachment content --id/, $rt_attach_id]);
-ok($contentret, "Ran the script ok");
-is($stdout, $image_data, "We roundtripped some binary");
-is($stderr, '');
-
+my ( $contentret, $stdout, $stderr )
+ = run_script( 'sd', [ qw/attachment content --id/, $rt_attach_id ] );
+ok( $contentret, "Ran the script ok" );
+is( $stdout, $image_data, "We roundtripped some binary" );
+is( $stderr, '' );
diag("Add an attachment to YATTA");
-my $MAKEFILE_CONTENT = file('Makefile.PL')->slurp;
-chomp($MAKEFILE_CONTENT);
+my $MAKEFILE_CONTENT = file('Makefile.PL')->slurp;
+chomp($MAKEFILE_CONTENT);
my $makefile_attach_uuid;
-run_output_matches('sd', [qw/ticket attachment create --id/, $yatta_id, '--file', 'Makefile.PL'], [qr/Created attachment (\d+) \((.*?)(?{ $makefile_attach_uuid = $2})\)/], [], "Added a attachment");
-
-
+run_output_matches(
+ 'sd',
+ [ qw/ticket attachment create --id/, $yatta_id, '--file', 'Makefile.PL' ],
+ [qr/Created attachment (\d+) \((.*?)(?{ $makefile_attach_uuid = $2})\)/],
+ [],
+ "Added a attachment"
+);
-my ($makefileret, $makefileout, $makefilerr) = run_script('sd', [qw/attachment content --uuid/, $makefile_attach_uuid]);
-is($makefileout, $MAKEFILE_CONTENT, "We inserted the makefile correctly");
+my ( $makefileret, $makefileout, $makefilerr )
+ = run_script( 'sd',
+ [ qw/attachment content --uuid/, $makefile_attach_uuid ] );
+is( $makefileout, $MAKEFILE_CONTENT, "We inserted the makefile correctly" );
diag("Push the attachment to RT");
( $ret, $out, $err ) = run_script( 'sd', [ 'push', '--to', $sd_rt_url ] );
diag("Check to see if the RT ticket has two attachments");
-my @two_attachments = sort { $a->file_name cmp $b->file_name } get_rt_ticket_attachments($tix[0]);
-is(scalar @two_attachments, 2, " I have two attachments on the RT side!");
+my @two_attachments = sort { $a->file_name cmp $b->file_name }
+ get_rt_ticket_attachments( $tix[0] );
+is( scalar @two_attachments, 2, " I have two attachments on the RT side!" );
my $makefile = shift @two_attachments;
-my $logo = shift @two_attachments;
-
-
-is ($logo->file_name, 'bplogo.gif');
-is ($makefile->file_name, 'Makefile.PL');
-is($makefile->content, $MAKEFILE_CONTENT , " The makefile's content was roundtripped ot rt ok");
-
-is($logo->content, file($IMAGE_FILE)->slurp, " The image's content was roundtripped ot rt ok");
+my $logo = shift @two_attachments;
+is( $logo->file_name, 'bplogo.gif' );
+is( $makefile->file_name, 'Makefile.PL' );
+is( $makefile->content, $MAKEFILE_CONTENT,
+ " The makefile's content was roundtripped ot rt ok" );
+
+is( $logo->content,
+ file($IMAGE_FILE)->slurp,
+ " The image's content was roundtripped ot rt ok"
+);
#diag $uuid;
# testing adding CCs to tickets
-$tick->add_cc('hiro at example.com'); # stored
-my ($tval,$tmsg) = $tick->store;
-ok($tval, $tmsg);
+$tick->add_cc('hiro at example.com'); # stored
+my ( $tval, $tmsg ) = $tick->store;
+ok( $tval, $tmsg );
my $fetched_tick = RT::Client::REST::Ticket->new(
rt => $rt,
- id => $tick->id)->retrieve;
-
+ id => $tick->id
+)->retrieve;
-diag($fetched_tick->subject);
+diag( $fetched_tick->subject );
my (@x) = $fetched_tick->cc;
-is_deeply (\@x, [ 'hiro at example.com']);
-( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
-ok($ret, $out);
+is_deeply( \@x, ['hiro at example.com'] );
+( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
+ok( $ret, $out );
-( $ret, $out, $err ) = run_script( 'sd', [ 'ticket', 'show', '--verbose','--id',$yatta_id ] );
+( $ret, $out, $err )
+ = run_script( 'sd', [ 'ticket', 'show', '--verbose', '--id', $yatta_id ] );
-like($out, qr/Cc:\s*hiro\@example.com/);
+like( $out, qr/Cc:\s*hiro\@example.com/ );
diag("resolve and comment on a ticket");
@@ -224,46 +245,53 @@
subject => 'helium',
)->store( text => "Ticket Comment" );
-( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
-ok($ret, $out);
+( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
+ok( $ret, $out );
my $helium_id;
-run_output_matches( 'sd', [ 'ticket', 'list', '--regex', 'helium' ],
- [qr/(.*?)(?{ $helium_id = $1 }) helium new/] );
+run_output_matches(
+ 'sd',
+ [ 'ticket', 'list', '--regex', 'helium' ],
+ [qr/(.*?)(?{ $helium_id = $1 }) helium new/]
+);
-( $ret, $out, $err ) = run_script( 'sd', [ 'ticket', 'comment', $helium_id, '--content', 'helium is a noble gas' ] );
-ok($ret, $out);
-like($out, qr/Created comment/);
-
-( $ret, $out, $err ) = run_script( 'sd', [ 'ticket', 'resolve', $helium_id ]);
-ok($ret, $out);
-like($out, qr/ticket .* updated/);
+( $ret, $out, $err )
+ = run_script( 'sd',
+ [ 'ticket', 'comment', $helium_id, '--content', 'helium is a noble gas' ] );
+ok( $ret, $out );
+like( $out, qr/Created comment/ );
+
+( $ret, $out, $err ) = run_script( 'sd', [ 'ticket', 'resolve', $helium_id ] );
+ok( $ret, $out );
+like( $out, qr/ticket .* updated/ );
( $ret, $out, $err ) = run_script( 'sd', [ 'push', '--to', $sd_rt_url ] );
-ok($ret, $out);
+ok( $ret, $out );
-( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
-ok($ret, $out);
-like($out, qr/No new changesets/);
+( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
+ok( $ret, $out );
+like( $out, qr/No new changesets/ );
my $fetched_ticket = RT::Client::REST::Ticket->new(
rt => $rt,
- id => $ticket->id)->retrieve;
+ id => $ticket->id
+)->retrieve;
-is($fetched_ticket->status, "resolved");
+is( $fetched_ticket->status, "resolved" );
sub get_rt_ticket_attachments {
my $ticket = shift;
- my $attachments = RT::Client::REST::Ticket->new( rt => $rt, id => $ticket)->attachments();
+ my $attachments = RT::Client::REST::Ticket->new( rt => $rt, id => $ticket )
+ ->attachments();
my $iterator = $attachments->get_iterator;
my @attachments;
- while (my $att = &$iterator) {
+ while ( my $att = &$iterator ) {
if ( $att->file_name ) {
- push @attachments, $att ;
+ push @attachments, $att;
}
}
- return @attachments
+ return @attachments;
}
1;
More information about the Bps-public-commit
mailing list