[Bps-public-commit] SD branch, master, updated. a2cdc75db814f41d9730e26fa87249af3a3edbf9

spang at bestpractical.com spang at bestpractical.com
Tue Aug 11 14:34:03 EDT 2009


The branch, master has been updated
       via  a2cdc75db814f41d9730e26fa87249af3a3edbf9 (commit)
       via  9c217b05313e68a14d97998022dc9c3c833e9ccf (commit)
      from  8686622a6d6bcd6079a3c16684d42424c693bb73 (commit)

Summary of changes:
 lib/App/SD/CLI/Command/Ticket/Comments.pm |    3 +
 t/sd-usage.t                              |  130 +++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+), 0 deletions(-)
 create mode 100644 t/sd-usage.t

- Log -----------------------------------------------------------------
commit 9c217b05313e68a14d97998022dc9c3c833e9ccf
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Aug 11 19:28:47 2009 +0100

    Ticket comments should print usage on -h

diff --git a/lib/App/SD/CLI/Command/Ticket/Comments.pm b/lib/App/SD/CLI/Command/Ticket/Comments.pm
index be658c5..7c5d5fa 100644
--- a/lib/App/SD/CLI/Command/Ticket/Comments.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Comments.pm
@@ -18,6 +18,9 @@ END_USAGE
 
 sub run {
     my $self = shift;
+
+    $self->print_usage if $self->has_arg('h');
+
     my $record = $self->_get_record_object;
 
     $self->require_uuid;

commit a2cdc75db814f41d9730e26fa87249af3a3edbf9
Author: Christine Spang <spang at bestpractical.com>
Date:   Tue Aug 11 19:31:01 2009 +0100

    Tests for SD-specific usage messages

diff --git a/t/sd-usage.t b/t/sd-usage.t
new file mode 100644
index 0000000..f4ed638
--- /dev/null
+++ b/t/sd-usage.t
@@ -0,0 +1,130 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use Prophet::Test tests => 18;
+use App::SD::Test;
+use App::SD::CLI;
+$Prophet::Test::CLI_CLASS = 'App::SD::CLI';
+
+$ENV{'PROPHET_REPO'} = $Prophet::Test::REPO_BASE . '/repo-' . $$;
+diag "Replica is in $ENV{PROPHET_REPO}";
+
+# additional tests for SD-specific usage methods
+
+run_command( 'init' );
+
+my @cmds = (
+    {
+        cmd     => [ qw(ticket create -h) ],
+        error   => [
+            'usage: sd-usage.t ticket create -- summary=foo status=open',
+            '       sd-usage.t ticket create [--edit]',
+        ],
+        comment => 'show usage',
+    },
+    {
+        cmd     => [ qw(ticket comments -h) ],
+        error   => [ 'usage: sd-usage.t ticket comments <ticket-id>' ],
+        comment => 'ticket comments usage',
+    },
+    {
+        cmd     => [ qw(ticket show -h) ],
+        error   => [
+            'usage: sd-usage.t ticket show <record-id> [options]',
+            '',
+            'Options are:',
+            "    -a|--all-props      Show props even if they aren't common",
+            "    -s|--skip-history   Don't show ticket history",
+            '    -h|--with-history   Show ticket history even if disabled in config',
+            '    -b|--batch',
+        ],
+        comment => 'ticket show usage',
+    },
+    {
+        cmd     => [ qw(ticket details -h) ],
+        error   => [
+            'usage: sd-usage.t ticket details <record-id> [options]',
+            '',
+            'Options are:',
+            "    -a|--all-props      Show props even if they aren't common",
+            '    -b|--batch',
+        ],
+        comment => 'ticket details usage',
+    },
+    {
+        cmd     => [ qw(ticket search -h) ],
+        error   => [
+            'usage: sd-usage.t ticket search',
+            '       sd-usage.t ticket search -- summary=~foo status!~new|open',
+        ],
+        comment => 'ticket search usage',
+    },
+    {
+        cmd     => [ qw(ticket ls -h) ],
+        error   => [
+            'usage: sd-usage.t ticket ls',
+            '       sd-usage.t ticket ls -- summary=~foo status!~new|open',
+        ],
+        comment => 'ticket ls usage',
+    },
+    {
+        cmd     => [ qw(ticket update -h) ],
+        error   => [
+            'usage: sd-usage.t ticket update <record-id> --edit [--all-props]',
+            '       sd-usage.t ticket update <record-id> -- status=open',
+        ],
+        comment => 'ticket update usage',
+    },
+    {
+        cmd     => [ qw(help -h) ],
+        error   => [ 'usage: sd-usage.t help [<topic>]' ],
+        comment => 'help usage',
+    },
+    {
+        cmd     => [ qw(browser -h) ],
+        error   => [ 'usage: sd-usage.t browser [--port <number>]' ],
+        comment => 'browser usage',
+    },
+);
+
+my $in_interactive_shell = 0;
+
+for my $item ( @cmds ) {
+    my $exp_error
+        = defined $item->{error}
+        ? (join "\n", @{$item->{error}})
+        : '';
+    my (undef, $got_error) = run_command( @{$item->{cmd}} );
+    {
+        local $/ = "";     # chomp paragraph mode
+        chomp $got_error;
+        chomp $exp_error;
+    }
+    is( $got_error, $exp_error, $item->{comment} . ' (non-shell)' );
+}
+
+$in_interactive_shell = 1;
+
+for my $item ( @cmds ) {
+    my $exp_error
+        = defined $item->{error}
+        ? (join "\n", @{$item->{error}}) . "\n"
+        : '';
+    # in an interactive shell, usage messages shouldn't be printing a command
+    # name
+    $exp_error =~ s/sd-usage.t //g;
+    my (undef, $got_error) = run_command( @{$item->{cmd}} );
+    {
+        local $/ = "";     # chomp paragraph mode
+        chomp $got_error;
+        chomp $exp_error;
+    }
+    is( $got_error, $exp_error, $item->{comment} . ' (in shell)');
+}
+
+no warnings 'redefine';
+sub Prophet::CLI::interactive_shell {
+    return $in_interactive_shell;
+}
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list