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.11';
3 4     4   1522 use base qw(Test::Builder::Module);
  4         4  
  4         1697  
4 4     4   178521 use strict;
  4         6  
  4         68  
5 4     4   13 use warnings;
  4         6  
  4         744  
6              
7             our @EXPORT = qw(store_ok);
8              
9             sub store_ok {
10 4     4 1 1697 my ( $store_class, $store_args ) = @_;
11 4         55 my $test = __PACKAGE__->builder;
12 4         75 $test->plan( tests => 12 );
13 4         3748 $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         2806 %{$store_args}
  4         57  
18             ),
19             'creating store object'
20             );
21 4         1931 $test->is_num( scalar $store->keys('test'), 0, 'no keys set initially' );
22 4         6917 $test->ok( $store->set( "test", "foo", "bar" ), "set foo to bar" );
23 4         1620 $test->is_num( scalar $store->keys('test'),
24             1, "storage namespace has 1 key" );
25 4         3901 $test->is_eq( $store->get( "test", "foo" ), "bar", "foo is set to bar" );
26 4         2811 $test->ok( $store->set( "test", "user_foo", "bar" ),
27             "set user_foo also to bar" );
28 4         1660 $test->is_num( scalar $store->keys('test'),
29             2, "storage namespace has 2 keys" );
30 4         4154 $test->is_num( scalar $store->keys( 'test', res => ['^user'] ),
31             1, "storage namespace has one key matching ^user" );
32 4         1866 $test->ok( $store->unset( "test", "foo" ), "unset key" );
33 4         2806 $test->ok( !$store->get( 'test', 'foo' ),
34             "unset has worked, no key namned foo left" );
35 4         1832 $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.11
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.