NAME
Plack::App::DAIA::Test - Test DAIA Servers
VERSION
version 0.43
SYNOPSIS
use Test::More;
use Plack::App::DAIA::Test;
use Your::App; # your subclass of Plack::App::DAIA
my $app = Your::App->new;
# or wrap a DAIA server
my $app = daia_app( 'http://your.host/pathtodaia' );
test_daia $app,
'some:id' => sub {
my $daia = shift; # or = $_
my @docs = $daia->document;
is (scalar @docs, 1, 'returned one document');
...
},
'another:id' => sub {
my $daia = shift;
...
};
# same usage, shown here with an inline server
test_daia_psgi
sub {
my $id = shift;
my $daia = DAIA::Response->new();
...
return $daia;
},
'some:id' => sub {
my $daia = $_; # or shift
...
};
done_testing;
DESCRIPTION
This model is experimental, so take care! The current version has different behaviour for test_daia
and test_daia_psgi
.
This module exports two methods for testing DAIA servers. You must provide a DAIA server as code reference or as instance of Plack::App::DAIA and a list of request identifiers and testing code. The testing code is passed a valid DAIA::Response object on success ($_
is also set to this response).
METHODS
test_daia ( $app, $id1 => sub { }, $id2 => ... )
Calls a DAIA server $app
's request method with one or more identifiers, each given a test function.
test_daia_psgi ( $app, $id => sub { }, $id => ... )
Calls a DAIA server $app
as PSGI application with one or more identifiers, each given a test function.
daia_test_suite ( $input [ %options ] )
Run a DAIA test suite from a string or stream (GLOB or IO::File). The only option supported so far is server
. A DAIA test suite lists servers, identifiers, and DAIA/JSON response fragments to test DAIA servers. The command line client provedaia is included in this distribution, see its documentation for further details.
daia_app ( $plack_app_daia | $url | $code )
Returns an instance of Plack::App::DAIA or undef. Code references or URLs are wrapped. For wrapped URLs $@
is set on failure. This method may be removed to be used internally only!
AUTHOR
Jakob Voss
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Jakob Voss.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.