Implement and test --check-spool. Make Mock/UserAgent save put and post data in an array. Make Percona/WebAPI/Client accept ready-made text resources, for multi-part resources.

This commit is contained in:
Daniel Nichter
2013-01-08 18:49:42 -07:00
parent d68301f293
commit 526437632c
6 changed files with 435 additions and 108 deletions

View File

@@ -31,8 +31,8 @@ sub new {
put => [],
},
content => {
post => undef,
put => undef,
post => [],
put => [],
},
};
return bless $self, $class;
@@ -42,7 +42,7 @@ sub request {
my ($self, $req) = @_;
my $type = lc($req->method);
if ( $type eq 'post' || $type eq 'put' ) {
$self->{content}->{$type} = $req->content;
push @{$self->{content}->{$type}}, $req->content;
}
my $r = shift @{$self->{responses}->{$type}};
my $c = $self->{encode}->($r->{content});

View File

@@ -233,12 +233,17 @@ sub _set {
my $res = $args{resources};
my $url = $args{url};
my $content;
my $content = '';
if ( ref($res) eq 'ARRAY' ) {
PTDEBUG && _d('List of resources');
$content = '[' . join(",\n", map { as_json($_) } @$res) . ']';
}
elsif ( -f $res ) {
PTDEBUG && _d('Reading content from file', $res);
elsif ( ref($res) ) {
PTDEBUG && _d('Resource object');
$content = as_json($res);
}
elsif ( $res !~ m/\n/ && -f $res ) {
PTDEBUG && _d('List of resources in file', $res);
$content = '[';
my $data = do {
local $INPUT_RECORD_SEPARATOR = undef;
@@ -250,7 +255,8 @@ sub _set {
$content .= $data;
}
else {
$content = as_json($res);
PTDEBUG && _d('Resource text');
$content = $res;
}
eval {