5a46a3fc720bce5849a20cb67bc52113ab8cc6e1
[catagits/catbook-code.git] / t / snippet_store / basic.t
1 use strict;
2 use warnings;
3 use Test::More qw(no_plan);
4
5 use_ok "LolCatalyst::Lite::SnippetStore";
6
7 my $store = LolCatalyst::Lite::SnippetStore->new;
8
9 my $num_snips = 3;
10
11 ok(
12   (my @snip = map $store->create({ text => "snippet $_" }), 1 .. $num_snips),
13   'Creates ok'
14 );
15
16 cmp_ok(scalar(@snip), '==', $num_snips, "$num_snips created");
17
18 is_deeply(\@snip, [ $store->all ], 'deep snippet check');
19
20 foreach my $snip (@snip) {
21   my $id = $snip->{id};
22   is($snip->{text}, $store->find($id)->{text}, "find by id $id ok");
23 }