test snippetstore translator requirement, improve debugging, fix app
[catagits/catbook-code.git] / t / snippet_store / basic.t
CommitLineData
a90d5246 1use strict;
2use warnings;
3use Test::More qw(no_plan);
26fe736a 4use Test::Exception;
a90d5246 5
6use_ok "LolCatalyst::Lite::SnippetStore";
7
26fe736a 8dies_ok {
9 LolCatalyst::Lite::SnippetStore->new;
10} 'Create without translator object fails';
11
12my $store = LolCatalyst::Lite::SnippetStore->new(translator => 'DUMMY');
a90d5246 13
14my $num_snips = 3;
15
16ok(
17 (my @snip = map $store->create({ text => "snippet $_" }), 1 .. $num_snips),
18 'Creates ok'
19);
20
21cmp_ok(scalar(@snip), '==', $num_snips, "$num_snips created");
22
23is_deeply(\@snip, [ $store->all ], 'deep snippet check');
24
25foreach my $snip (@snip) {
26 my $id = $snip->{id};
27 is($snip->{text}, $store->find($id)->{text}, "find by id $id ok");
28}