comment saving
[scpubgit/Commentry.git] / t / comment_store.t
CommitLineData
4628d9c9 1use strictures 1;
2use Test::More;
24b96449 3use File::Path;
4628d9c9 4use aliased 'App::Commentry::CommentStore';
5use aliased 'App::Commentry::Comment';
6
7my $store = CommentStore->new(base_dir => 't/var/exstore');
8
9is_deeply(
10 [ $store->get({ path => 'not/there' })->flatten ],
11 [], 'Nonexistent set is empty'
12);
13
14is_deeply(
15 [ $store->get({ path => 'one/two/three' })->flatten ],
16 [ map Comment->new({ title => "Title $_", body => "Body $_" }), 1, 2 ],
17 'Existing set loads ok'
18);
19
24b96449 20my $create = { title => 'Created title', body => 'Created body' };
21
22is_deeply(
23 $store->get({ path => 'create/new' })->add($create),
24 my $new = Comment->new($create),
25 'Create new ok'
26);
27
28$store->clear_cache;
29
30is_deeply(
31 [ $store->get({ path => 'create/new' })->flatten ],
32 [ $new ],
33 'Reload ok'
34);
35
36rmtree('t/var/exstore/create');
37
4628d9c9 38done_testing;