Graham Ollis

NAME

Test::Clustericious - Test Clustericious apps

VERSION

version 0.9937

SYNOPSIS

 use Test::Clustericious;

 my $t = Test::Clustericious->new(app => 'SomeMojoApp');
 my $t = Test::Clustericious->new(server => 'myapp');
 my $t = Test::Clustericious->new(server_url => 'http://foo');

 my $obj = $t->create_ok('/my/url', { my => 'object' }); # 2 tests

 my $obj = $t->retrieve_ok('/url/id'); # 2 tests, returns decoded object

 $t->update_ok('/url/id', { my => 'object' }); # 2 tests

 $t->remove_ok('/url/id'); # 6 tests: deletes, then gets to verify gone

DESCRIPTION

Test::Clustericious is a collection of testing helpers for everyone developing Clustericious applications. It inherits from Test::Mojo, and add the following new attributes and methods.

ATTRIBUTES

server

 my $t = Test::Clustericious->new(server => 'MyServer');

Looks up the URL for the server in the config file for the specified server.

server_url

 my $t = Test::Clustericious->new(server_url => 'http://foo/');

Explicitly define a server url to test against.

METHODS

new

 my $t = Test::Clustericious(app => 'SomeMojoApp');
 my $t = Test::Clustericious(server => 'myapp');
 my $t = Test::Clustericious(server_url => 'http://foo'); 

testdata

 my $object = $t->testdata('filename');

Looks for filename, filename.json, filename.yaml in 't', 'data' or 't/data' directories. Parses with json or yaml if appropriate, then returns the object.

decoded_body

 $obj = $t->decoded_body;

Returns the body from the last request, parsing with JSON if Content-Type is application/json.

Returns undef if the parse fails or the last request wasn't status 2xx.

create_ok

 $obj = $t->create_ok('/url', { some => 'object' });
 $obj = $t->create_ok('/url', 'filename');
 $t->create_ok('/url', <many/files*>);

if called with a filename, loads the object from the file as described in testdata().

Uses POST to the url to create the object, encoded with JSON. Checks for status 200 and returns the decoded body.

You can also create multiple objects/files at once, but then there is no returned object.

This counts as 2 TAP tests.

update_ok

 update_ok is really just an alias for create_ok

retrieve_ok

 $obj = $t->retrieve_ok('/url');

Makes a GET request on the url, checks for status 200, and returns the decoded body.

This counts as 2 TAP tests.

remove_ok

 $t->remove_ok($url);

Makes a DELETE request on the url, checks for status 200 and content of 'ok'. Then does a GET of the same url and checks for not found.

This counts as 6 TAP tests.

notfound_ok

 $t->notfound_ok($url[, $object]);

Makes a GET request on the url, or if $object specified, a POST request the encoded object and checks for a 404 response code and "not found" or "null".

This counts as 3 TAP tests.

truncate_ok

 $t->truncate_ok($url);

Makes a GET request the URL, which should return a list of keys, then iterates over the list and delete_ok() each one.

SEE ALSO

Clustericious

AUTHOR

original author: Brian Duggan

current maintainer: Graham Ollis <plicease@cpan.org>

contributors:

Curt Tilmes

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by NASA GSFC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.




Hosting generously
sponsored by Bytemark