Brian Duggan > Clustericious-0.9910 > Test::Clustericious

Download:
Clustericious-0.9910.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source   Latest Release: Clustericious-0.9940_02

NAME ^

Test::Clustericious - Test Clustericious apps

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');

 GETs the url, checks for status 200, and returns the decoded body.

 This counts as 2 TAP tests.

remove_ok

 $t->remove_ok($url);

 DELETEs 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]);

 GETs the url, or if $object specified, POSTs 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);

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

SEE ALSO ^

Clustericious

syntax highlighting: