File Coverage

blib/lib/Test/Bot/BasicBot/Pluggable/Store.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 30 30 100.0


line stmt bran cond sub pod time code
1             package Test::Bot::BasicBot::Pluggable::Store;
2             $Test::Bot::BasicBot::Pluggable::Store::VERSION = '1.10';
3 4     4   1671 use base qw(Test::Builder::Module);
  4         5  
  4         1767  
4 4     4   182954 use strict;
  4         5  
  4         88  
5 4     4   13 use warnings;
  4         7  
  4         777  
6              
7             our @EXPORT = qw(store_ok);
8              
9             sub store_ok {
10 4     4 1 1875 my ( $store_class, $store_args ) = @_;
11 4         57 my $test = __PACKAGE__->builder;
12 4         85 $test->plan( tests => 12 );
13 4         2969 $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         1426 %{$store_args}
  4         57  
18             ),
19             'creating store object'
20             );
21 4         1174 $test->is_num( scalar $store->keys('test'), 0, 'no keys set initially' );
22 4         6292 $test->ok( $store->set( "test", "foo", "bar" ), "set foo to bar" );
23 4         866 $test->is_num( scalar $store->keys('test'),
24             1, "storage namespace has 1 key" );
25 4         3241 $test->is_eq( $store->get( "test", "foo" ), "bar", "foo is set to bar" );
26 4         2359 $test->ok( $store->set( "test", "user_foo", "bar" ),
27             "set user_foo also to bar" );
28 4         794 $test->is_num( scalar $store->keys('test'),
29             2, "storage namespace has 2 keys" );
30 4         3443 $test->is_num( scalar $store->keys( 'test', res => ['^user'] ),
31             1, "storage namespace has one key matching ^user" );
32 4         1404 $test->ok( $store->unset( "test", "foo" ), "unset key" );
33 4         2252 $test->ok( !$store->get( 'test', 'foo' ),
34             "unset has worked, no key namned foo left" );
35 4         1509 $test->is_eq( $store->namespaces(), 'test', "return namespaces" );
36             }
37              
38             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.10
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.