[Bps-public-commit] r17553 - sd/trunk/t/sd-rt

jesse at bestpractical.com jesse at bestpractical.com
Sun Jan 4 20:53:05 EST 2009


Author: jesse
Date: Sun Jan  4 20:53:05 2009
New Revision: 17553

Added:
   sd/trunk/t/sd-rt/bogus-rt-data.t
      - copied, changed from r17465, /sd/trunk/t/sd-rt/basic.t

Log:
* test file that explodes when rt has messy db 

Copied: sd/trunk/t/sd-rt/bogus-rt-data.t (from r17465, /sd/trunk/t/sd-rt/basic.t)
==============================================================================
--- /sd/trunk/t/sd-rt/basic.t	(original)
+++ sd/trunk/t/sd-rt/bogus-rt-data.t	Sun Jan  4 20:53:05 2009
@@ -15,7 +15,7 @@
     }
 }
 
-use Prophet::Test tests => 43;
+use Prophet::Test tests => 6;
 use App::SD::Test;
 
 no warnings 'once';
@@ -34,6 +34,9 @@
 
 $RT::Test::SKIP_REQUEST_WORK_AROUND = 1;
 
+
+diag("This test file makes sure that when someone has messed with RT's internal history, prophet doesn't explode");
+
 my ( $url, $m ) = RT::Test->started_ok;
 
 use RT::Client::REST;
@@ -55,279 +58,47 @@
 
 my ( $ret, $out, $err );
 ( $ret, $out, $err ) = run_script( 'sd', [ 'clone', '--from', $sd_rt_url ] );
-my ( $yatta_id, $flyman_id );
+my ( $flyman_id );
 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'] );
+RT::Client::REST::Ticket->new( rt     => $rt, id     => $ticket->id, status => 'open',)->store();
+diag("AB");
 ( $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
 
-run_output_matches(
-    'sd',
-    [ 'ticket', 'create', '--', '--summary', 'YATTA', '--status', 'new' ],
-    [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" ]
-);
-
 ( $ret, $out, $err ) = run_script( 'sd', [ 'push', '--to', $sd_rt_url ] );
 diag($out);
 diag($err);
-my @tix = $rt->search(
-    type  => 'ticket',
-    query => "Subject='YATTA'"
-);
-
-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", ]
-);
-
-RT::Client::REST::Ticket->new(
-    rt     => $rt,
-    id     => $ticket->id,
-    status => 'stalled',
-)->store();
+diag("DE");
+diag("FE");
+RT::Client::REST::Ticket->new( rt     => $rt, id     => $ticket->id, status => 'stalled',)->store();
 
 ( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
-
+diag("XE");
 run_output_matches_unordered(
     'sd',
     [ 'ticket',              'list', '--regex', '.' ],
-    [ "$yatta_id YATTA new", "$flyman_id Fly Man stalled", ]
-);
-
-RT::Client::REST::Ticket->new(
-    rt     => $rt,
-    id     => $tix[0],
-    status => 'open',
-)->store();
-
-diag("===> bad pull");
-( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
-run_output_matches_unordered(
-    'sd',
-    [ '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]
-);
-
-my @attachments = get_rt_ticket_attachments( $tix[0] );
-
-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', '.' ],
-    [ "$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/]
-);
-ok($rt_attach_id);
-
-diag(
-    "Check to see if YATTA's attachment is binary-identical to the original one"
+    [ "$flyman_id Fly Man stalled", ]
 );
 
-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, '' );
-
-diag("Add an attachment to YATTA");
-
-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"
-);
-
-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 $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"
-);
+$RT::Handle->dbh->do("UPDATE Tickets SET Status = 'rejected' WHERE id = ".$ticket->id);
+RT::Client::REST::Ticket->new( rt     => $rt, id     => $ticket->id, status => 'open',)->store();
 
-#diag $uuid;
-# testing adding CCs to tickets
 
-$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;
-
-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 );
-
-( $ret, $out, $err )
-    = run_script( 'sd', [ 'ticket', 'show', '--verbose', '--id', $yatta_id ] );
-
-like( $out, qr/"cc"\s+set\s+to\s+"hiro\@example.com"/ );
-
-diag("resolve and comment on a ticket");
-
-$ticket = RT::Client::REST::Ticket->new(
-    rt      => $rt,
-    queue   => 'General',
-    status  => 'new',
-    subject => 'helium',
-)->store( text => "Ticket Comment" );
-
-( $ret, $out, $err ) = run_script( 'sd', [ 'pull', '--from', $sd_rt_url ] );
-ok( $ret, $out );
-
-my $helium_id;
-run_output_matches(
+run_output_matches_unordered(
     'sd',
-    [ 'ticket', 'list', '--regex', 'helium' ],
-    [qr/(.*?)(?{ $helium_id = $1 }) helium new/]
+    [ 'ticket',              'list', '--regex', '.' ],
+    [ "$flyman_id Fly Man open", ]
 );
 
-( $ret, $out, $err )
-    = run_script( 'sd',
-    [ 'ticket', 'comment', $helium_id, '--content', 'helium is a noble gas' ] );
-ok( $ret, $out );
-like( $out, qr/Created comment/ );
-
-
-{    # resolve a ticket
-    ( $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 );
-
-    ( $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;
-
-    is( $fetched_ticket->status, "resolved" );
-}
-
-{    # delete a ticket for reals
-    ( $ret, $out, $err )
-        = run_script( 'sd', [ 'ticket','delete', $flyman_id]);
-    ok( $ret, $out );
-    like( $out, qr/ticket .* deleted/ );
-
-    ( $ret, $out, $err ) = run_script( 'sd', [ 'push', '--to', $sd_rt_url ] );
-    ok( $ret, $out );
-    diag($out);
-    ( $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 => $flyman_rt_id 
-    )->retrieve;
-
-    is( $fetched_ticket->status, "deleted" );
-
-}
-
-
-
-
-
-
-sub get_rt_ticket_attachments {
-    my $ticket = shift;
-
-    my $attachments = RT::Client::REST::Ticket->new( rt => $rt, id => $ticket )
-        ->attachments();
-    my $iterator = $attachments->get_iterator;
-    my @attachments;
-    while ( my $att = &$iterator ) {
-        if ( $att->file_name ) {
-            push @attachments, $att;
-        }
-    }
-    return @attachments;
-}
-
 1;
 



More information about the Bps-public-commit mailing list