PONAPI-Server
view release on metacpan or search on metacpan
xt/001-server-with-client.t view on Meta::CPAN
#!perl
use strict;
use warnings;
use Test::More;
use Plack::Test::Server;
use Data::Dumper;
use PONAPI::Server;
use IPC::Cmd qw/can_run/;
delete @ENV{qw/ HTTP_PROXY http_proxy /};
# Rather than just testing PONAPI::Client, let's make sure we're
# working on other backends too. We always test PONAPI::Client,
# but if available, we'll also test HTTP::Tiny and curl on the
# command line.
my $have_ponapi_client = do { local $@; !!eval { require PONAPI::Client; 1 } };
my $have_http_tiny = do { local $@; !!eval { require HTTP::Tiny; 1 } };
my $have_curl = can_run('curl');
if ( !$have_ponapi_client && !$have_http_tiny && !$have_curl ) {
plan skip_all => 'Client cannot be loaded, not running these tests'
}
my $media_type = 'application/vnd.api+json';
my $author_attributes = {
name => 'New!',
age => 11,
gender => 'female',
};
my $article_2 = {
data => {
type => "articles",
id => 2,
links => { self => "/articles/2" },
attributes => {
body => "The 2nd shortest article. Ever.",
created => "2015-06-22 14:56:29",
status => "ok",
title => "A second title",
updated => "2015-06-22 14:56:29"
},
relationships => {
authors => {
data => {
id => 88,
type => "people"
},
links => {
related => "/articles/2/authors",
self => "/articles/2/relationships/authors"
}
},
comments => {
data => [
{
id => 5,
type => "comments"
},
{
id => 12,
type => "comments"
}
],
links => {
related => "/articles/2/comments",
self => "/articles/2/relationships/comments"
}
}
( run in 0.878 second using v1.01-cache-2.11-cpan-71847e10f99 )