[Bps-public-commit] r16946 - sd/trunk/lib/App/SD

ruz at bestpractical.com ruz at bestpractical.com
Thu Nov 20 10:48:34 EST 2008


Author: ruz
Date: Thu Nov 20 10:48:32 2008
New Revision: 16946

Modified:
   sd/trunk/lib/App/SD/Test.pm

Log:
* add get_ticket_info function in SD::Test

Modified: sd/trunk/lib/App/SD/Test.pm
==============================================================================
--- sd/trunk/lib/App/SD/Test.pm	(original)
+++ sd/trunk/lib/App/SD/Test.pm	Thu Nov 20 10:48:32 2008
@@ -8,7 +8,7 @@
 use File::Spec;
 use Cwd qw/getcwd/;
 use base qw/Exporter/;
-our @EXPORT = qw(create_ticket_ok create_ticket_with_editor_ok create_ticket_comment_ok get_uuid_for_luid get_luid_for_uuid);
+our @EXPORT = qw(create_ticket_ok create_ticket_with_editor_ok create_ticket_comment_ok get_uuid_for_luid get_luid_for_uuid get_ticket_info);
 $ENV{'SD_CONFIG'} = 't/prophet_testing.conf';
 delete $ENV{'PROPHET_APP_CONFIG'};
 $ENV{'EDITOR'} = '/bin/true';
@@ -157,6 +157,42 @@
     );
 }
 
+=head2 get_ticket_info LUID/UUID
+
+Returns a hash reference with information about ticket.
+
+=cut
+
+sub get_ticket_info {
+    my $id = shift;
+    my ($ok, $out, $err) =  Prophet::Test::run_script( 'sd', [qw(ticket show --batch --id), $id ]);
+
+    my @lines = split /\n/, $out;
+
+    my %res;
+    my $section = '';
+    while ( defined( $_ = shift @lines ) ) {
+        if ( /^= ([A-Z]+)\s*$/ ) {
+            $section = lc $1;
+            next;
+        }
+        next unless $section;
+
+        if ( $section eq 'metadata' ) {
+            next unless /^(\w+):\s*(.*?)\s*$/;
+            $res{$section}{$1} = $2;
+        }
+    }
+
+    if ( $res{'metadata'}{'id'} ) {
+        @{ $res{'metadata'} }{'luid', 'uuid'} = (
+            $res{'metadata'}{'id'} =~ /^\d+\s+\(.*?\)\s*$/
+        );
+    }
+
+    return \%res;
+}
+
 =head2 set_editor SCRIPT
 
 Sets the editor that Proc::InvokeEditor uses (which is used for nicer ticket



More information about the Bps-public-commit mailing list