SYNOPSIS
use Test::More tests => 2;
use Net::Respite::Server::Test qw(setup_test_server);
my $client = setup_test_server({
service => 'bam', # necessary because we directly subclassed Net::Respite::Server
api_meta => 'Bam', # ditto
client_utf8_encoded => 1,
flat => 1,
});
ok(1, "Test");
my $resp = $client->some_api_method({
some_key => 'some_val',
});
is($resp->{'some_return_key'}, 'some_return_val', 'A test');
DESCRIPTION
Returns a client and optional configured server. Tests can then be run against the client.
OPTIONS
The main function is setup_test_server. It accepts a hashref with the following options.
- server
-
Optional - if not passed, it will try and use server_class to create the object.
- server_class
-
Optional - if not passed it will try and use api_meta and service.
- service
-
Name of the service - typically only used if Net::Respite::Server is used directly - otherwise it will default to the server_name of the server with _server removed.
- api_meta
-
Only used if Net::Respite::Server is used - information about the API itself.
- client_utf8_encoded
-
If your libraries are always working with utf8 encoded data - set this (not necessary for some APIs).
- no_ssl
-
Test the API without using ssl
- no_brand
-
This API does not require Brand.
- flat
-
Make the client return flat data results.
- host
-
Default localhost - what hostname to bind.
- pass
-
API password - defaults to 123qwe
- port
-
Randomly chosen.
- pid_file, access_file, log_file
-
File locations of the server files, defaults to File::Test files. Auto cleaned up.
- server_type
-
Default to Fork. Could use PreFork or Single too.
- client
-
Default undef. Can pass in your own client object.
- client_class
-
Default Net::Respite::Class. What API client to use.
- user
-
Which user to run the server as - defaults to current user.
- group
-
Which group to run the server as - defaults to current group.