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.20';
3 4     4   1710 use base qw(Test::Builder::Module);
  4         4  
  4         1584  
4 4     4   168938 use strict;
  4         7  
  4         66  
5 4     4   12 use warnings;
  4         5  
  4         742  
6              
7             our @EXPORT = qw(store_ok);
8              
9             sub store_ok {
10 4     4 1 1532 my ( $store_class, $store_args ) = @_;
11 4         50 my $test = __PACKAGE__->builder;
12 4         71 $test->plan( tests => 12 );
13 4         2826 $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         1624 %{$store_args}
  4         61  
18             ),
19             'creating store object'
20             );
21 4         1174 $test->is_num( scalar $store->keys('test'), 0, 'no keys set initially' );
22 4         6122 $test->ok( $store->set( "test", "foo", "bar" ), "set foo to bar" );
23 4         1094 $test->is_num( scalar $store->keys('test'),
24             1, "storage namespace has 1 key" );
25 4         3481 $test->is_eq( $store->get( "test", "foo" ), "bar", "foo is set to bar" );
26 4         2585 $test->ok( $store->set( "test", "user_foo", "bar" ),
27             "set user_foo also to bar" );
28 4         1049 $test->is_num( scalar $store->keys('test'),
29             2, "storage namespace has 2 keys" );
30 4         3602 $test->is_num( scalar $store->keys( 'test', res => ['^user'] ),
31             1, "storage namespace has one key matching ^user" );
32 4         1587 $test->ok( $store->unset( "test", "foo" ), "unset key" );
33 4         2408 $test->ok( !$store->get( 'test', 'foo' ),
34             "unset has worked, no key namned foo left" );
35 4         1602 $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.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.