App-SD

 view release on metacpan or  search on metacpan

t/sd-rt/basic.t  view on Meta::CPAN

    " The makefile's content was roundtripped ot rt ok" );

is( $logo->content,
    scalar Prophet::Util->slurp( $IMAGE_FILE ),
    " The image's content was roundtripped ot rt ok"
);

#diag $uuid;
# testing adding CCs to tickets

$tick->add_cc('hiro@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@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(
    '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/ );


{    # 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 );

    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/i );

    ( $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 );

    my $fetched_ticket = RT::Client::REST::Ticket->new(
        rt => $rt,
        id => $flyman_rt_id 
    )->retrieve;
    TODO: {
    local $TODO = "Deleting tickets in RT still doesn't play nicely with SD";
    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;



( run in 1.050 second using v1.01-cache-2.11-cpan-39bf76dae61 )