1use strict;
2use warnings;
3
4use Test::Deep;
5use RT::Test::Shredder tests => undef, config => 'Set($Organization, "foo-bar");';
6my $test = "RT::Test::Shredder";
7
8use_ok('RT::Shredder::Plugin::Tickets');
9
10$test->create_savepoint('clean');
11
12diag "Shred a queue whose name contains a hyphen";
13{
14    my $ticket = RT::Test->create_ticket( Subject => 'Test organization with a hyphen', Queue => 1 );
15    $ticket->ApplyTransactionBatch;
16
17    my $plugin = RT::Shredder::Plugin::Tickets->new;
18    my ( $status, $msg ) = $plugin->TestArgs( query => 'id = ' . $ticket->id );
19    ok( $status, "plugin arguments are ok" ) or diag "error: $msg";
20
21    my $shredder = $test->shredder_new();
22
23    ( $status, my $tickets ) = $plugin->Run;
24    ok( $status, "executed plugin successfully" );
25    is( $tickets->Count,     1,           'found one ticket' );
26    is( $tickets->First->id, $ticket->id, 'found the ticket' );
27
28    $shredder->PutObjects( Objects => [ 'RT::Ticket-' . RT->Config->Get('Organization') . '-' . $ticket->id ] );
29    $shredder->WipeoutAll;
30
31    cmp_deeply( $test->dump_current_and_savepoint('clean'), "current DB equal to savepoint" );
32}
33
34done_testing();
35