[Rt-commit] r8462 - in rt/branches/3.7-EXPERIMENTAL-TUNIS: lib/RT
lib/t
ruz at bestpractical.com
ruz at bestpractical.com
Wed Aug 8 20:42:26 EDT 2007
Author: ruz
Date: Wed Aug 8 20:42:24 2007
New Revision: 8462
Modified:
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/utils.pl
rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gateway.t
Log:
* move send_via_mailgate from lib/t/utils.pl
* deprecate lib/t/utils.pl, but leav for backward compatibility
for a while
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm Wed Aug 8 20:42:24 2007
@@ -287,4 +287,23 @@
return ($?, $result);
}
+sub send_via_mailgate {
+ my $self = shift;
+ my $message = shift;
+ my %args = (@_);
+
+ my ($status, $gate_result) = $self->run_mailgate( message => $message, %args );
+
+ my $id;
+ unless ( $status >> 8 ) {
+ ($id) = ($gate_result =~ /Ticket:\s*(\d+)/i);
+ unless ( $id ) {
+ diag "Couldn't find ticket id in text:\n$gate_result" if $ENV{'TEST_VERBOSE'};
+ }
+ } else {
+ diag "Mailgate output:\n$gate_result" if $ENV{'TEST_VERBOSE'};
+ }
+ return ($status, $id);
+}
+
1;
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/utils.pl
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/utils.pl (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/t/utils.pl Wed Aug 8 20:42:24 2007
@@ -6,23 +6,15 @@
use RT;
RT::LoadConfig();
+warn "lib/t/utils.pl has been deprecated. Use RT::Test module instead";
+
sub run_gate {
require RT::Test;
return RT::Test->run_mailgate(@_);
}
sub create_ticket_via_gate {
- my $message = shift;
- my ($status, $gate_result) = run_gate( message => $message, @_ );
- my $id;
- unless ( $status >> 8 ) {
- ($id) = ($gate_result =~ /Ticket:\s*(\d+)/i);
- unless ( $id ) {
- diag "Couldn't find ticket id in text:\n$gate_result" if $ENV{'TEST_VERBOSE'};
- }
- } else {
- diag "Mailgate output:\n$gate_result" if $ENV{'TEST_VERBOSE'};
- }
- return ($status, $id);
+ require RT::Test;
+ return RT::Test->send_via_mailgate(@_);
}
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gateway.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gateway.t (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/mail/gateway.t Wed Aug 8 20:42:24 2007
@@ -69,8 +69,6 @@
# TODO: --extension queue
-require "lib/t/utils.pl";
-
my $url = $m->rt_base_url;
sub latest_ticket {
@@ -90,7 +88,7 @@
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text, url => undef);
+ my ($status, $id) = RT::Test->send_via_mailgate($text, url => undef);
is ($status >> 8, 1, "The mail gateway exited with a failure");
ok (!$id, "No ticket id") or diag "by mistake ticket #$id";
}
@@ -104,7 +102,7 @@
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text, url => 'http://this.test.for.non-connection.is.expected.to.generate.an.error');
+ my ($status, $id) = RT::Test->send_via_mailgate($text, url => 'http://this.test.for.non-connection.is.expected.to.generate.an.error');
is ($status >> 8, 75, "The mail gateway exited with a failure");
ok (!$id, "No ticket id");
}
@@ -132,7 +130,7 @@
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text);
+ my ($status, $id) = RT::Test->send_via_mailgate($text);
is ($status >> 8, 0, "The mail gateway exited normally");
ok ($id, "Created ticket");
@@ -152,7 +150,7 @@
Foob!
EOF
local $ENV{'EXTENSION'} = "bad value with\nnewlines\n";
- my ($status, $id) = create_ticket_via_gate($text);
+ my ($status, $id) = RT::Test->send_via_mailgate($text);
is ($status >> 8, 0, "The mail gateway exited normally");
ok ($id, "Created ticket #$id");
@@ -187,7 +185,7 @@
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text, extension => 'some-extension-arg' );
+ my ($status, $id) = RT::Test->send_via_mailgate($text, extension => 'some-extension-arg' );
is ($status >> 8, 0, "The mail gateway exited normally");
ok ($id, "Created ticket #$id");
@@ -221,7 +219,7 @@
Blah!
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text, extension => 'some-extension-arg' );
+ my ($status, $id) = RT::Test->send_via_mailgate($text, extension => 'some-extension-arg' );
is ($status >> 8, 0, "The mail gateway exited normally");
ok ($id, "Created ticket #$id");
@@ -241,7 +239,7 @@
Blah!
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text);
+ my ($status, $id) = RT::Test->send_via_mailgate($text);
is ($status >> 8, 0, "The mail gateway exited normally");
ok (!$id, "no ticket created");
@@ -275,7 +273,7 @@
Blah!
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text);
+ my ($status, $id) = RT::Test->send_via_mailgate($text);
is ($status >> 8, 0, "The mail gateway exited normally");
ok ($id, "ticket created");
@@ -301,7 +299,7 @@
Blah! (Should not work.)
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text);
+ my ($status, $id) = RT::Test->send_via_mailgate($text);
is ($status >> 8, 0, "The mail gateway exited normally");
ok (!$id, "no way to reply to the ticket");
@@ -329,7 +327,7 @@
Blah!
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text);
+ my ($status, $id) = RT::Test->send_via_mailgate($text);
is ($status >> 8, 0, "The mail gateway exited normally");
is ($id, $ticket_id, "replied to the ticket");
@@ -349,7 +347,7 @@
Foob!
EOF
local $ENV{'EXTENSION'} = $ticket_id;
- my ($status, $id) = create_ticket_via_gate($text, extension => 'ticket');
+ my ($status, $id) = RT::Test->send_via_mailgate($text, extension => 'ticket');
is ($status >> 8, 0, "The mail gateway exited normally");
is ($id, $ticket_id, "replied to the ticket");
@@ -380,7 +378,7 @@
Blah! (Should not work.)
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text, action => 'comment');
+ my ($status, $id) = RT::Test->send_via_mailgate($text, action => 'comment');
is ($status >> 8, 0, "The mail gateway exited normally");
ok (!$id, "no way to comment on the ticket");
@@ -409,7 +407,7 @@
Blah!
Foob!
EOF
- my ($status, $id) = create_ticket_via_gate($text, action => 'comment');
+ my ($status, $id) = RT::Test->send_via_mailgate($text, action => 'comment');
is ($status >> 8, 0, "The mail gateway exited normally");
is ($id, $ticket_id, "replied to the ticket");
@@ -429,7 +427,7 @@
Foob!
EOF
local $ENV{'EXTENSION'} = 'comment';
- my ($status, $id) = create_ticket_via_gate($text, extension => 'action');
+ my ($status, $id) = RT::Test->send_via_mailgate($text, extension => 'action');
is ($status >> 8, 0, "The mail gateway exited normally");
is ($id, $ticket_id, "added comment to the ticket");
@@ -474,7 +472,7 @@
Encoding => 'base64',
);
# Create a ticket with a binary attachment
- my ($status, $id) = create_ticket_via_gate($entity);
+ my ($status, $id) = RT::Test->send_via_mailgate($entity);
is ($status >> 8, 0, "The mail gateway exited normally");
ok ($id, "created ticket");
@@ -530,7 +528,7 @@
\303\241\303\251\303\255\303\263\303\272
bye
EOF
- my ($status, $id) = create_ticket_via_gate($text);
+ my ($status, $id) = RT::Test->send_via_mailgate($text);
is ($status >> 8, 0, "The mail gateway exited normally");
ok ($id, "created ticket");
@@ -566,7 +564,7 @@
\303\241\303\251\303\255\303\263\303\272
bye
EOF
- my ($status, $id) = create_ticket_via_gate($text);
+ my ($status, $id) = RT::Test->send_via_mailgate($text);
is ($status >> 8, 0, "The mail gateway exited normally");
ok ($id, "created ticket");
More information about the Rt-commit
mailing list