| 1 | package Test::Bot::BasicBot::Pluggable::Store; | ||
| 2 | 4 | $Test::Bot::BasicBot::Pluggable::Store::VERSION = '1.20'; | |
| 3 | 4 | ▶ | use base qw(Test::Builder::Module); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 4 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 4 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 4 | our @EXPORT = qw(store_ok); | |
| 8 | |||
| 9 | sub store_ok { | ||
| 10 | 4 | ▶ | my ( $store_class, $store_args ) = @_; |
|
Subroutine
store_ok: called CC=1 SCAR=0.0
Pod
documented
| |||
| 11 | 4 | my $test = __PACKAGE__->builder; | |
| 12 | 4 | $test->plan( tests => 12 ); | |
| 13 | 4 | $test->ok( eval "require Bot::BasicBot::Pluggable::Store::$store_class", | |
| 14 | 'loading store class' ); | ||
| 15 | $test->ok( | ||
| 16 | my $store = "Bot::BasicBot::Pluggable::Store::$store_class"->new( | ||
| 17 | 4 | %{$store_args} | |
| 18 | ), | ||
| 19 | 'creating store object' | ||
| 20 | ); | ||
| 21 | 4 | $test->is_num( scalar $store->keys('test'), 0, 'no keys set initially' ); | |
| 22 | 4 | $test->ok( $store->set( "test", "foo", "bar" ), "set foo to bar" ); | |
| 23 | 4 | $test->is_num( scalar $store->keys('test'), | |
| 24 | 1, "storage namespace has 1 key" ); | ||
| 25 | 4 | $test->is_eq( $store->get( "test", "foo" ), "bar", "foo is set to bar" ); | |
| 26 | 4 | $test->ok( $store->set( "test", "user_foo", "bar" ), | |
| 27 | "set user_foo also to bar" ); | ||
| 28 | 4 | $test->is_num( scalar $store->keys('test'), | |
| 29 | 2, "storage namespace has 2 keys" ); | ||
| 30 | 4 | $test->is_num( scalar $store->keys( 'test', res => ['^user'] ), | |
| 31 | 1, "storage namespace has one key matching ^user" ); | ||
| 32 | 4 | $test->ok( $store->unset( "test", "foo" ), "unset key" ); | |
| 33 | 4 | $test->ok( !$store->get( 'test', 'foo' ), | |
| 34 | "unset has worked, no key namned foo left" ); | ||
| 35 | 4 | $test->is_eq( $store->namespaces(), 'test', "return namespaces" ); | |
| 36 | } | ||
| 37 | |||
| 38 | 4 | 1; | |
| 39 | |||
| 40 | __END__ | ||
| 41 | |||
| 42 | =head1 NAME | ||
| 43 | |||
| 44 | Test::Bot::BasicBot::Pluggable::Store - basics tests for Bot::BasicBot::Pluggable storage classes | ||
| 45 | |||
| 46 | =head1 VERSION | ||
| 47 | |||
| 48 | version 1.20 | ||
| 49 | |||
| 50 | =head1 SYNOPSIS | ||
| 51 | |||
| 52 | store_ok( 'Memory' ); | ||
| 53 | store_ok( 'Deep', { file => 'deep.db' }); | ||
| 54 | |||
| 55 | =head1 DESCRIPTION | ||
| 56 | |||
| 57 | This modules collects some general functions to test storage module | ||
| 58 | sfor Bot::BasicBot::Pluggable. In the moment we just export the | ||
| 59 | basic store_ok. | ||
| 60 | |||
| 61 | =head1 FUNCTIONS | ||
| 62 | |||
| 63 | =head2 store_ok | ||
| 64 | |||
| 65 | This functions justs tests some basic behaviour every storage module | ||
| 66 | should provide, like store creation, get and set. You can't use it | ||
| 67 | directly with Test::More as we harcode the number of tests to nine | ||
| 68 | in the moment. (Man, i'm so excited about nested tap streams in the | ||
| 69 | newest development release of Test::Simple) | ||
| 70 | |||
| 71 | =head1 AUTHOR | ||
| 72 | |||
| 73 | Mario Domgoergen <mdom@cpan.org> | ||
| 74 | |||
| 75 | This program is free software; you can redistribute it | ||
| 76 | and/or modify it under the same terms as Perl itself. | ||