Plack::App::DAIA::Test - Test DAIA Servers
version 0.48
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;
This model is experimental, so take care! The current version has different behaviour for test_daia and test_daia_psgi, that might get fixed.
test_daia
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).
$_
Calls a DAIA server $app's retrieve method with one or more identifiers, each given a test function. This does not add warnings and the error option is ignored (use test_daia_psgi instead if needed).
$app
Calls a DAIA server $app as PSGI application with one or more identifiers, each given a test function.
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!
$@
Plack::App::DAIA::Test::Suite and provedaia.
Jakob Voss
This software is copyright (c) 2012 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.
To install Plack::App::DAIA, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::App::DAIA
CPAN shell
perl -MCPAN -e shell install Plack::App::DAIA
For more information on module installation, please visit the detailed CPAN module installation guide.