simple in-memory snippet store
[catagits/catbook-code.git] / t / snippet_store / basic.t
diff --git a/t/snippet_store/basic.t b/t/snippet_store/basic.t
new file mode 100644 (file)
index 0000000..5a46a3f
--- /dev/null
@@ -0,0 +1,23 @@
+use strict;
+use warnings;
+use Test::More qw(no_plan);
+
+use_ok "LolCatalyst::Lite::SnippetStore";
+
+my $store = LolCatalyst::Lite::SnippetStore->new;
+
+my $num_snips = 3;
+
+ok(
+  (my @snip = map $store->create({ text => "snippet $_" }), 1 .. $num_snips),
+  'Creates ok'
+);
+
+cmp_ok(scalar(@snip), '==', $num_snips, "$num_snips created");
+
+is_deeply(\@snip, [ $store->all ], 'deep snippet check');
+
+foreach my $snip (@snip) {
+  my $id = $snip->{id};
+  is($snip->{text}, $store->find($id)->{text}, "find by id $id ok");
+}