Test::...::Redis(3pm)
π Test::...::Redis(3pm) π
okay bestie, so this is a User Contributed Perl Documentation page for Test::Mock::Redis β the fake-Redis-for-testing module you've been looking for. it's a .3pm manpage, meaning it's Perl module docs, and we're gonna walk it all the way through. grab a boba, we're going in π§β¨
β¨ NAME β¨
Test::Mock::Redis β use this in place of Redis for unit testing π«Ά
πΈ VERSION πΈ
Version 0.22 β that's the one, bestie.
π¦ SYNOPSIS π¦
so the whole point: Test::Mock::Redis can be used in place of Redis for running tests without needing a running redis instance. no server, no daemon, no tears. ππ
use Test::Mock::Redis;
my $redis = Test::Mock::Redis->new(server => 'whatever');
$redis->set($key, 'some value');
$redis->get($key);
...
this module is designed to function as a drop in replacement for Redis.pm for testing purposes. periodt. π
check perldoc Redis and the redis documentation at <http://redis.io> for the real deal, iykyk.
π PERSISTENCE π
okay this part is lowkey iconic. the "connection" to the mocked server (and its stored data) will persist beyond the object instance, just like a real Redis server. π
that means you do not need to save the instance to this object in order to preserve your data. simply call new with the same server parameter and the same instance will be returned, with all data preserved. no cap. π§
it's giving "the server never left, you did." πβ¨
π SUBROUTINES/METHODS π
π new π
Create a new Test::Mock::Redis object.
It can be used in place of a Redis object for unit testing.
It accepts the server argument, just like Redis.pm's new.
π num_databases π
Redis ships with a default of 16 databases, and that's what this module handles by default. if you need to change that, do:
use Test::Mock::Redis num_databases => 21;
or at run-time:
Test::Mock::Redis::change_num_databases(21);
β PIPELINING β
See "PIPELINING" in Redis β most methods support the use of a callback sub as the final argument. π«Ά
for this implementation specifically: the callback sub will be called immediately (before the result of the original method is returned), and wait_all_responses does nothing. also, combining pipelining with multi/exec is not supported. so don't. π
π TODO π
Lots! π bestie we are so honest here.
- Not all Redis functionality is implemented. The test files that output
TODOare still to be done. - The top of all test files [except
01-basic.t] has the list of commands tested or to-be tested in the file.
so here's the little legend, it's giving grade-school report card:
- those marked with an
xare pretty well-tested. - those marked with an
oneed help. π₯Ί - those that are unmarked have no tests, or are un-implemented.
for example:
x AUTH <--- has some tests
o KEYS <--- only partially tested and/or implemented
ZINTERSTORE <--- not tested (or maybe not implemented)
beyond that, it would be neat to add methods to inspect how often keys were accessed and get other information that allows the module user to confirm that their code interacted with redis (or Test::Mock::Redis) as they expected. future plans, slay. β¨
π«Ά AUTHOR π«Ά
Jeff Lavallee, "<jeff at zeroclue.com>"
π SEE ALSO π
The real Redis.pm client whose interface this module mimics: <http://search.cpan.org/dist/Redis>
π₯ BUGS π₯
Please report any bugs or feature requests to "bug-mock-redis at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Mock-Redis>.
the author will be notified, and then you'll automatically be notified of progress on your bug as changes get made. so like, a little notification chain. cute. π
πΈ SUPPORT πΈ
You can find documentation for this module with the perldoc command.
perldoc Test::Mock::Redis
You can also look for information at:
- RT: CPAN's request tracker
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Mock-Redis>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/Test-Mock-Redis>
- CPAN Ratings
<http://cpanratings.perl.org/d/Test-Mock-Redis>
- Search CPAN
<http://search.cpan.org/dist/Test-Mock-Redis/>
π ACKNOWLEDGEMENTS π
Salvatore Sanfilippo for redis, of course! π
Dobrica Pavlinusic & Pedro Melo for Redis.pm
The following people have contributed to Test::Mock::Redis:
- Chris Reinhardt
- Ian Burrell
- Gianni Ceccarelli
- Karen Etheridge
- Keith Broughton
- Kevin Goess
- Neil Bowers
- Nigel Gregoire
- Thomas Bloor
- Valery Kalesnik
- Yaakov Shaul
the whole group chat showed up. legends, every one. πβ¨
π LICENSE AND COPYRIGHT π
Copyright 2018 Jeff Lavallee.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See <http://dev.perl.org/licenses/> for more information.
and that's a wrap, bestie π«Ά this lil page came to you via perl v5.36.0, dated 2022-10-16, and it's filed under Test::...::Redis(3pm). go forth and mock responsibly π
π
π¦ where this page comes from
- ubuntu noble: libtest-mock-redis-perl 0.22-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-mock-redis-perl 0.22-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-mock-redis-perl 0.22-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms