The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Plack::App::DAIA::Test - Test DAIA Servers

VERSION

version 0.47

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, that might get fixed.

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_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!

SEE ALSO

Plack::App::DAIA::Test::Suite and provedaia.

AUTHOR

Jakob Voss

COPYRIGHT AND LICENSE

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.