API-Client
view release on metacpan or search on metacpan
t/API_Client.t view on Meta::CPAN
ok my $result = $tryable->result;
;
});
$subs->scenario('deleting', fun($tryable) {
ok my $result = $tryable->result;
;
});
$subs->scenario('transacting', fun($tryable) {
ok my $result = $tryable->result;
;
});
$subs->scenario('subclassing', fun($tryable) {
ok my $result = $tryable->result;
ok $result->isa('Hookbin');
ok $result->isa('API::Client');
is_deeply $result->auth, ['admin', 'secret'];
is_deeply $result->headers, [['Accept', '*/*']];
is_deeply $result->base, ['https://httpbin.org/get'];
is $result->url->to_string, 'https://httpbin.org/get';
is $result->name, 'Hookbin (0.01)';
});
$subs->example(-1, 'create', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'post';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{json}, {active => 1};
$result
});
$subs->example(-1, 'delete', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'delete';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{json}, undef;
is_deeply $json->{form}, {};
is $json->{data}, '';
$result
});
$subs->example(-1, 'dispatch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'get';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{args}, {};
$result
});
$subs->example(-2, 'dispatch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'post';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is $json->{data}, "active=1";
$result
});
$subs->example(-3, 'dispatch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'get';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{args}, {active => 1};
$result
});
$subs->example(-4, 'dispatch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'post';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{json}, {active => 1};
$result
});
$subs->example(-5, 'dispatch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'post';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is $json->{data}, "active=1";
$result
});
$subs->example(-6, 'dispatch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'put';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{json}, {active => 1};
$result
});
$subs->example(-7, 'dispatch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'patch';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{json}, {active => 1};
$result
});
$subs->example(-8, 'dispatch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'delete';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{json}, {active => 1};
$result
});
$subs->example(-1, 'fetch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'get';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{json}, undef;
is_deeply $json->{form}, undef;
is $json->{data}, undef;
$result
});
$subs->example(-1, 'patch', 'method', fun($tryable) {
ok my $result = $tryable->result;
my $req = $result->req;
is lc($req->method), 'patch';
my $res = $result->res;
is $res->code, 200;
my $json = $res->json;
is $json->{headers}{'Host'}, 'httpbin.org';
is $json->{headers}{'Content-Type'}, 'application/json';
is_deeply $json->{json}, {active => 1};
$result
});
$subs->example(-1, 'prepare', 'method', fun($tryable) {
ok my $result = $tryable->result;
$result
});
$subs->example(-1, 'process', 'method', fun($tryable) {
ok my $result = $tryable->result;
$result
});
$subs->example(-1, 'resource', 'method', fun($tryable) {
ok my $result = $tryable->result;
is $result->debug, 0;
is $result->fatal, 0;
like $result->name, qr/API::Client \(\d.\d\d\)/;
is $result->retries, 0;
is $result->timeout, 10;
is $result->url->to_string, 'https://httpbin.org/status/200';
$result
});
$subs->example(-1, 'serialize', 'method', fun($tryable) {
ok my $result = $tryable->result;
is $result->{debug}, 0;
is $result->{fatal}, 0;
like $result->{name}, qr/API::Client \(\d.\d\d\)/;
is $result->{retries}, 0;
is $result->{timeout}, 10;
is $result->{url}, 'https://httpbin.org';
$result
});
$subs->example(-1, 'update', 'method', fun($tryable) {
ok my $result = $tryable->result;
( run in 0.549 second using v1.01-cache-2.11-cpan-f0fbb3f571b )