Daisuke Murase > Test-RedisServer-0.14 > Test::RedisServer

Download:
Test-RedisServer-0.14.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  1
View/Report Bugs
Module Version: 0.14   Source  

NAME ^

Test::RedisServer - redis-server runner for tests.

SYNOPSIS ^

    use Redis;
    use Test::RedisServer;
    use Test::More;
    
    my $redis_server;
    eval {
        $redis_server = Test::RedisServer->new;
    } or plan skip_all => 'redis-server is required to this test';
    
    my $redis = Redis->new( $redis_server->connect_info );
    
    is $redis->ping, 'PONG', 'ping pong ok';
    
    done_testing;

DESCRIPTION ^

METHODS ^

new(%options)

    my $redis_server = Test::RedisServer->new(%options);

Create a new redis-server instance, and start it by default (auto_start option avoid this)

Available options are:

start

Start redis-server instance manually.

exec

Just exec to redis-server instance. This method is useful to use this module with Test::TCP, Proclet or etc.

    use File::Temp;
    use Test::TCP;
    my $tmp_dir = File::Temp->newdir( CLEANUP => 1 );

    test_tcp(
        client => sub {
            my ($port, $server_pid) = @_;
            ...
        },
        server => sub {
            my ($port) = @_;
            my $redis = Test::RedisServer->new(
                auto_start => 0,
                conf       => { port => $port },
                tmpdir     => $tmp_dir,
            );
            $redis->exec;
        },
    );

stop

Stop redis-server instance.

This method automatically called when object was DESTROY.

connect_info

Return connection info for client library to connect this redis-server instance.

This parameter is designed to pass directly to Redis module.

    my $redis_server = Test::RedisServer->new;
    my $redis = Redis->new( $redis_server->connect_info );

pid

Return redis-server instance's process id, or undef when redis-server is not running.

wait_exit

Block until redis instance exited.

SEE ALSO ^

Test::mysqld for mysqld.

Test::Memcached for Memcached.

This module steals lots of stuffs from above modules.

Test::Mock::Redis, another approach for testing redis application.

INTERNAL METHODS ^

BUILD

DEMOLISH

AUTHOR ^

Daisuke Murase <typester@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (c) 2012 KAYAC Inc. All rights reserved.

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

The full text of the license can be found in the LICENSE file included with this module.

syntax highlighting: