Commit | Line | Data |
a90d5246 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More qw(no_plan); |
28d1f68e |
4 | use Test::Exception; |
a90d5246 |
5 | |
6 | use_ok "LolCatalyst::Lite::SnippetStore"; |
7 | |
8 | my $store = LolCatalyst::Lite::SnippetStore->new; |
9 | |
28d1f68e |
10 | dies_ok { |
11 | $store->create({ text => "earth shattering kaboom" }); |
12 | } 'Create without translator object fails'; |
13 | |
14 | $store = LolCatalyst::Lite::SnippetStore->new(translator => 'DUMMY'); |
15 | |
a90d5246 |
16 | my $num_snips = 3; |
17 | |
18 | ok( |
19 | (my @snip = map $store->create({ text => "snippet $_" }), 1 .. $num_snips), |
20 | 'Creates ok' |
21 | ); |
22 | |
23 | cmp_ok(scalar(@snip), '==', $num_snips, "$num_snips created"); |
24 | |
25 | is_deeply(\@snip, [ $store->all ], 'deep snippet check'); |
26 | |
27 | foreach my $snip (@snip) { |
28 | my $id = $snip->{id}; |
29 | is($snip->{text}, $store->find($id)->{text}, "find by id $id ok"); |
30 | } |