[Bps-public-commit] r17672 - in sd/trunk: .

spang at bestpractical.com spang at bestpractical.com
Fri Jan 9 07:50:04 EST 2009


Author: spang
Date: Fri Jan  9 07:50:03 2009
New Revision: 17672

Modified:
   sd/trunk/   (props changed)
   sd/trunk/t/06-ticket-show.t

Log:
 r53459 at loki:  spang | 2009-01-09 14:47:58 +0200
 refactor this test case to not be such a pain in the ass every time the output format changes


Modified: sd/trunk/t/06-ticket-show.t
==============================================================================
--- sd/trunk/t/06-ticket-show.t	(original)
+++ sd/trunk/t/06-ticket-show.t	Fri Jan  9 07:50:03 2009
@@ -23,56 +23,69 @@
 # create from sd
 my ($ticket_id, $ticket_uuid) = create_ticket_ok( '--summary', 'YATTA');
 
+sub check_output_with_history {
+    my @extra_args = @_;
+
+    run_output_matches( 'sd', [ 'ticket', 'show', $ticket_id, @extra_args ],
+        [
+            '',
+            '= METADATA',
+            '',
+            "id:               $ticket_id ($ticket_uuid)",
+            'summary:          YATTA',
+            'status:           ' . colored('new', 'red'),
+            'milestone:        alpha',
+            'component:        core',
+            qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
+            qr/^creator:\s+$ENV{USER}$/,
+            qr/reporter:\s+$ENV{EMAIL}$/,
+            qr/original_replica:\s+$replica_uuid$/,
+            '',
+            '= HISTORY',
+            '',
+            qr/^ $ENV{USER} at \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\s+\(\d+\@$replica_uuid\)$/,
+            "  + \"original_replica\" set to \"$replica_uuid\"",
+            "  + \"creator\" set to \"$ENV{USER}\"",
+            '  + "status" set to "new"',
+            "  + \"reporter\" set to \"$ENV{EMAIL}\"",
+            qr/^  \+ "created" set to "\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}"$/,
+            '  + "component" set to "core"',
+            '  + "summary" set to "YATTA"',
+            '  + "milestone" set to "alpha"',
+            '',
+        ]
+    );
+}
+
+
+sub check_output_without_history {
+    my @extra_args = @_;
+
+    run_output_matches( 'sd', [ 'ticket', 'show', $ticket_id, @_],
+        [
+            '',
+            '= METADATA',
+            '',
+            "id:               $ticket_id ($ticket_uuid)",
+            'summary:          YATTA',
+            'status:           ' . colored('new', 'red'),
+            'milestone:        alpha',
+            'component:        core',
+            qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
+            qr/^creator:\s+$ENV{USER}$/,
+            qr/reporter:\s+$ENV{EMAIL}$/,
+            qr/original_replica:\s+$replica_uuid$/,
+        ]
+    );
+}
+
 diag('default (shows history)');
 
-run_output_matches( 'sd', [ 'ticket', 'show', $ticket_id ],
-    [
-        '',
-        '= METADATA',
-        '',
-        "id:               $ticket_id ($ticket_uuid)",
-        'summary:          YATTA',
-        'status:           ' . colored('new', 'red'),
-        'milestone:        alpha',
-        'component:        core',
-        qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
-        qr/^creator:\s+$ENV{USER}$/,
-        qr/reporter:\s+$ENV{EMAIL}$/,
-        qr/original_replica:\s+$replica_uuid$/,
-        '',
-        '= HISTORY',
-        '',
-        qr/^ $ENV{USER} at \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\s+\(\d+\@$replica_uuid\)$/,
-        "  + \"original_replica\" set to \"$replica_uuid\"",
-        "  + \"creator\" set to \"$ENV{USER}\"",
-        '  + "status" set to "new"',
-        "  + \"reporter\" set to \"$ENV{EMAIL}\"",
-        qr/^  \+ "created" set to "\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}"$/,
-        '  + "component" set to "core"',
-        '  + "summary" set to "YATTA"',
-        '  + "milestone" set to "alpha"',
-        '',
-    ]
-);
+check_output_with_history();
 
 diag("passing --skip history (doesn't show history)");
 
-run_output_matches( 'sd', [ 'ticket', 'show', $ticket_id, '--skip-history'],
-    [
-        '',
-        '= METADATA',
-        '',
-        "id:               $ticket_id ($ticket_uuid)",
-        'summary:          YATTA',
-        'status:           ' . colored('new', 'red'),
-        'milestone:        alpha',
-        'component:        core',
-        qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
-        qr/^creator:\s+$ENV{USER}$/,
-        qr/reporter:\s+$ENV{EMAIL}$/,
-        qr/original_replica:\s+$replica_uuid$/,
-    ]
-);
+check_output_without_history('--skip-history');
 
 my $config_filename = $ENV{'SD_REPO'} . '/sdrc';
 App::SD::Test->write_to_file($config_filename,
@@ -82,74 +95,15 @@
 diag("config option disable_ticket_show_history_by_default set");
 diag("(shouldn't show history)");
 
-run_output_matches( 'sd', [ 'ticket', 'show', $ticket_id ],
-    [
-        '',
-        '= METADATA',
-        '',
-        "id:               $ticket_id ($ticket_uuid)",
-        'summary:          YATTA',
-        'status:           ' . colored('new', 'red'),
-        'milestone:        alpha',
-        'component:        core',
-        qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
-        qr/^creator:\s+$ENV{USER}$/,
-        qr/reporter:\s+$ENV{EMAIL}$/,
-        qr/original_replica:\s+$replica_uuid$/,
-    ]
-);
+check_output_without_history();
 
 diag("config option disable_ticket_show_history_by_default set");
 diag("and --skip-history passed (shouldn't show history)");
 
-run_output_matches( 'sd', [ 'ticket', 'show', $ticket_id, '--skip-history'],
-    [
-        '',
-        '= METADATA',
-        '',
-        "id:               $ticket_id ($ticket_uuid)",
-        'summary:          YATTA',
-        'status:           ' . colored('new', 'red'),
-        'milestone:        alpha',
-        'component:        core',
-        qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
-        qr/^creator:\s+$ENV{USER}$/,
-        qr/reporter:\s+$ENV{EMAIL}$/,
-        qr/original_replica:\s+$replica_uuid$/,
-    ]
-);
+check_output_without_history('--skip-history');
 
 # config option set and --show-history passed (should show history)
 diag('config option disable_ticket_show_history_by_default set');
 diag('and --show-history passed (should show history)');
 
-run_output_matches( 'sd', [ 'ticket', 'show', $ticket_id, '--show-history' ],
-    [
-        '',
-        '= METADATA',
-        '',
-        "id:               $ticket_id ($ticket_uuid)",
-        'summary:          YATTA',
-        'status:           ' . colored('new', 'red'),
-        'milestone:        alpha',
-        'component:        core',
-        qr/^created:\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/,
-        qr/^creator:\s+$ENV{USER}$/,
-        qr/reporter:\s+$ENV{EMAIL}$/,
-        qr/original_replica:\s+$replica_uuid$/,
-        '',
-        '= HISTORY',
-        '',
-        qr/^ $ENV{USER} at \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\s+\(\d+\@$replica_uuid\)$/,
-        "  + \"original_replica\" set to \"$replica_uuid\"",
-        "  + \"creator\" set to \"$ENV{USER}\"",
-        '  + "status" set to "new"',
-        "  + \"reporter\" set to \"$ENV{EMAIL}\"",
-        qr/^  \+ "created" set to "\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}"$/,
-        '  + "component" set to "core"',
-        '  + "summary" set to "YATTA"',
-        '  + "milestone" set to "alpha"',
-        '',
-    ]
-);
-
+check_output_with_history('--show-history');



More information about the Bps-public-commit mailing list