[Bps-public-commit] r13814 - in sd/trunk: bin t
jesse at bestpractical.com
jesse at bestpractical.com
Sat Jul 5 06:33:01 EDT 2008
Author: jesse
Date: Sat Jul 5 06:32:59 2008
New Revision: 13814
Modified:
sd/trunk/bin/sd
sd/trunk/lib/App/SD/Model/Attachment.pm
sd/trunk/t/attachment-content.t
sd/trunk/t/sd-attachments.t
sd/trunk/t/sd-rt.t
Log:
tests all pass
Modified: sd/trunk/bin/sd
==============================================================================
--- sd/trunk/bin/sd (original)
+++ sd/trunk/bin/sd Sat Jul 5 06:32:59 2008
@@ -48,19 +48,19 @@
-package App::SD::CLI::Model::TicketComment::Create;
+package App::SD::CLI::Command::Ticket::Comment::Create;
use Moose;
extends 'Prophet::CLI::Command::Create';
with 'App::SD::CLI::Model::TicketComment';
+with 'App::SD::CLI::Command';
-
-sub run {
+override run => sub {
my $self = shift;
- $self->args->{'ticket'} = $self->uuid;
+ $self->args->{'ticket'} = $self->cli->uuid;
$self->args->{'content'} = $self->get_content('comment');
- $self->SUPER::run(@_);
-}
+ super(@_);
+};
# override args to feed in that ticket's uuid as an argument to the comment
@@ -69,10 +69,10 @@
use Moose;
extends 'Prophet::CLI::Command::Create';
with 'App::SD::CLI::Model::Attachment';
+with 'App::SD::CLI::Command';
override run => sub {
my $self = shift;
- warn "here";
$self->args->{'content'} = $self->get_content('attachment');
super(@_);
@@ -85,8 +85,7 @@
override run => sub {
my $self = shift;
- warn YAML::Dump($self); use YAML;
- #$self->args->{'ticket'} = $self->uuid;
+ $self->args->{'ticket'} = $self->cli->uuid;
super(@_);
};
@@ -117,7 +116,7 @@
sub run {
my $self = shift;
- my $record = $self->_get_record;
+ my $record = $self->_get_record_class;
$record->load(uuid => $self->cli->uuid);
print $record->prop('content');
}
@@ -180,7 +179,7 @@
sub run {
my $self = shift;
- my $record = App::SD::Model::Ticket->new( handle => $self->cli->app_handle->handle);
+ my $record = $self->_get_record_class();
$record->load( uuid => $self->uuid );
unless (@{$record->comments}) {
print "No comments found\n";
Modified: sd/trunk/lib/App/SD/Model/Attachment.pm
==============================================================================
--- sd/trunk/lib/App/SD/Model/Attachment.pm (original)
+++ sd/trunk/lib/App/SD/Model/Attachment.pm Sat Jul 5 06:32:59 2008
@@ -8,7 +8,7 @@
use constant collection_class => 'App::SD::Collection::Attachment';
use constant record_type => 'attachment';
-use constant summary_format => '%u %s %s';
+use constant summary_format => '%l %s %s';
use constant summary_props => qw(name content_type);
__PACKAGE__->register_reference( ticket => 'App::SD::Model::Ticket');
Modified: sd/trunk/t/attachment-content.t
==============================================================================
--- sd/trunk/t/attachment-content.t (original)
+++ sd/trunk/t/attachment-content.t Sat Jul 5 06:32:59 2008
@@ -35,7 +35,7 @@
my $attachment_id;
run_output_matches(
'sd',
- [ qw/ticket attachment create --ticket/, $yatta_uuid, '--file', $file ],
+ [ qw/ticket attachment create --uuid/, $yatta_uuid, '--file', $file ],
[ qr/Created attachment (\d+)(?{$attachment_id = $1}) \((.*?)(?{ $attachment_uuid = $2})\)$/
],
[],
@@ -44,8 +44,8 @@
ok($attachment_uuid);
run_output_matches(
'sd',
- [ qw/ticket attachment list --ticket/, $yatta_uuid ],
- [ $attachment_uuid . " paper_order.doc text/plain" ],
+ [ qw/ticket attachment list --uuid/, $yatta_uuid ],
+ [ $attachment_id . " paper_order.doc text/plain" ],
,
[],
"Found the attachment, but doesn't show the content"
@@ -64,7 +64,7 @@
my $image_attach;
my $image_file = 't/data/bplogo.gif';
-run_output_matches('sd', [qw/ticket attachment create --ticket/, $yatta_uuid, '--file', $image_file], [qr/Created attachment (\d+)(?{ $image_attach = $1})/], [], "Added a attachment");
+run_output_matches('sd', [qw/ticket attachment create --uuid/, $yatta_uuid, '--file', $image_file], [qr/Created attachment (\d+)(?{ $image_attach = $1})/], [], "Added a attachment");
my $image_data = file($image_file)->slurp;
my ($ret, $stdout, $stderr) = run_script('sd', [qw/attachment content --id/, $image_attach]);
Modified: sd/trunk/t/sd-attachments.t
==============================================================================
--- sd/trunk/t/sd-attachments.t (original)
+++ sd/trunk/t/sd-attachments.t Sat Jul 5 06:32:59 2008
@@ -21,11 +21,10 @@
my $attachment_id;
my $attachment_uuid;
-run_output_matches('sd', [qw/ticket attachment create --id/, $yatta_uuid, '--content', 'stub', '--name', "paper_order.doc"], [qr/Created attachment (\d+)(?{ $attachment_id = $1}) \((.*)(?{ $attachment_uuid = $2})\)/], [], "Added a attachment");
-ok($attachment_id);
-
-run_output_matches('sd', [qw/ticket attachment list --id/, $yatta_uuid], [qr/\d+ paper_order.doc text\/plain/,], [], "Found the attachment");
+run_output_matches('sd', [qw/ticket attachment create --uuid/, $yatta_uuid, '--content', 'stub', '--name', "paper_order.doc"], [qr/Created attachment (\d+)(?{ $attachment_id = $1}) \((.*)(?{ $attachment_uuid = $2})\)/], [], "Added a attachment");
+ok($attachment_id, " $attachment_id = $attachment_uuid");
+run_output_matches('sd', [qw/ticket attachment list --uuid/, $yatta_uuid], [qr/\d+ paper_order.doc text\/plain/,], [], "Found the attachment");
run_output_matches(
'sd',
[ qw/ticket attachment show --id/, $attachment_id ],
@@ -42,7 +41,7 @@
);
run_output_matches(
'sd',
- [ qw/ticket attachment update --id/, $attachment_uuid,
+ [ qw/ticket attachment update --uuid/, $attachment_uuid,
qw/--name/, "plague_recipe.doc"
],
[qr/attachment $attachment_uuid updated/],
@@ -51,7 +50,7 @@
);
run_output_matches(
'sd',
- [ qw/ticket attachment show --id/, $attachment_uuid ],
+ [ qw/ticket attachment show --uuid/, $attachment_uuid ],
[
qr/id: (\d+) \($attachment_uuid\)/,
"content_type: text/plain",
@@ -65,7 +64,7 @@
run_output_matches(
'sd',
- [ qw/ticket attachment list --id/, $yatta_uuid ],
+ [ qw/ticket attachment list --uuid/, $yatta_uuid ],
[qr/plague_recipe/],
[],
"Found the attachment when we tried to search for all attachments on a ticket by the ticket's uuid"
Modified: sd/trunk/t/sd-rt.t
==============================================================================
--- sd/trunk/t/sd-rt.t (original)
+++ sd/trunk/t/sd-rt.t Sat Jul 5 06:32:59 2008
@@ -143,14 +143,14 @@
diag("check to see if YATTA has an attachment");
-my $rt_attach_uuid;
-run_output_matches( sd => [qw/ticket attachment list --id/, $yatta_id], [qr/(.*?)(?{ $rt_attach_uuid = $1 }) bplogo.gif image\/gif/] );
-ok($rt_attach_uuid);
+my $rt_attach_id;
+run_output_matches( sd => [qw/ticket attachment list --id/, $yatta_id], [qr/(.*?)(?{ $rt_attach_id = $1 }) bplogo.gif image\/gif/] );
+ok($rt_attach_id);
diag("Check to see if YATTA's attachment is binary-identical to the original one");
my $image_data = file($IMAGE_FILE)->slurp;
-my ($contentret, $stdout, $stderr) = run_script('sd', [qw/attachment content --uuid/, $rt_attach_uuid]);
+my ($contentret, $stdout, $stderr) = run_script('sd', [qw/attachment content --id/, $rt_attach_id]);
ok($contentret, "Ran the script ok");
is($stdout, $image_data, "We roundtripped some binary");
is($stderr, '');
More information about the Bps-public-commit
mailing list