[Rt-commit] r5995 - in rt/branches/3.7-EXPERIMENTAL: . lib/t

ruz at bestpractical.com ruz at bestpractical.com
Tue Sep 19 10:25:59 EDT 2006


Author: ruz
Date: Tue Sep 19 10:25:59 2006
New Revision: 5995

Added:
   rt/branches/3.7-EXPERIMENTAL/lib/t/utils.pl
Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/t/regression/06mailgateway.t

Log:
 r3777 at cubic-pc:  cubic | 2006-09-19 18:36:12 +0400
 Tests
 * add lib/t/utils.pl
 * move gate test utils into utils.pl


Modified: rt/branches/3.7-EXPERIMENTAL/lib/t/regression/06mailgateway.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/t/regression/06mailgateway.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/t/regression/06mailgateway.t	Tue Sep 19 10:25:59 2006
@@ -61,66 +61,15 @@
 RT::Init();
 use RT::Tickets;
 
-use IPC::Open2;
 use MIME::Entity;
 use Digest::MD5;
 use LWP::UserAgent;
 
 # TODO: --extension queue
 
-my $url = RT->Config->Get('WebURL');
-
-our $mailgate = $RT::BinPath .'/rt-mailgate';
-die "Couldn't find mailgate ($mailgate) command" unless -f $mailgate;
-$mailgate .= ' --debug';
-
-sub run_gate {
-    my %args = (
-        url     => $url,
-        message => '',
-        action  => 'correspond',
-        queue   => 'General',
-        @_
-    );
-    my $message = delete $args{'message'};
-
-    my $cmd = $mailgate;
-    while( my ($k,$v) = each %args ) {
-        next unless $v;
-        $cmd .= " --$k '$v'";
-    }
-    $cmd .= ' 2>&1';
+require "lib/t/utils.pl";
 
-    DBIx::SearchBuilder::Record::Cachable->FlushCache;
-
-    my ($child_out, $child_in);
-    my $pid = open2($child_out, $child_in, $cmd);
-    if ( UNIVERSAL::isa($message, 'MIME::Entity') ) {
-        $message->print( $child_in );
-    } else {
-        print $child_in $message;
-    }
-    close $child_in;
-    my $result = do { local $/; <$child_out> };
-    close $child_out;
-    waitpid $pid, 0;
-    return ($?, $result);
-}
-
-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);
-}
+my $url = RT->Config->Get('WebURL');
 
 sub latest_ticket {
     my $tickets = RT::Tickets->new( $RT::SystemUser );

Added: rt/branches/3.7-EXPERIMENTAL/lib/t/utils.pl
==============================================================================
--- (empty file)
+++ rt/branches/3.7-EXPERIMENTAL/lib/t/utils.pl	Tue Sep 19 10:25:59 2006
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT;
+RT::LoadConfig();
+
+use IPC::Open2;
+
+our $url = RT->Config->Get('WebURL');
+our $mailgate = $RT::BinPath .'/rt-mailgate';
+die "Couldn't find mailgate ($mailgate) command" unless -f $mailgate;
+$mailgate .= ' --debug';
+
+sub run_gate {
+    my %args = (
+        url     => $url,
+        message => '',
+        action  => 'correspond',
+        queue   => 'General',
+        @_
+    );
+    my $message = delete $args{'message'};
+
+    my $cmd = $mailgate;
+    while( my ($k,$v) = each %args ) {
+        next unless $v;
+        $cmd .= " --$k '$v'";
+    }
+    $cmd .= ' 2>&1';
+
+    DBIx::SearchBuilder::Record::Cachable->FlushCache;
+
+    my ($child_out, $child_in);
+    my $pid = open2($child_out, $child_in, $cmd);
+    if ( UNIVERSAL::isa($message, 'MIME::Entity') ) {
+        $message->print( $child_in );
+    } else {
+        print $child_in $message;
+    }
+    close $child_in;
+    my $result = do { local $/; <$child_out> };
+    close $child_out;
+    waitpid $pid, 0;
+    return ($?, $result);
+}
+
+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);
+}
+


More information about the Rt-commit mailing list