Skip to content
This repository
Browse code

Added basic tests for List Lystyng::Schema::List.

  • Loading branch information...
commit f9429d5df110e47b054db7ad47707a09d5981b5b 1 parent 665b831
Dave Cross authored January 30, 2014
42  t/Test/Lystyng/Schema/Result/List.pm
... ...
@@ -0,0 +1,42 @@
  1
+package Test::Lystyng::Schema::Result::List;
  2
+
  3
+use base qw(Test::Class);
  4
+use Test::More;
  5
+use Moose;
  6
+
  7
+with 'Test::Role::WithSchema';
  8
+
  9
+sub basic : Tests {
  10
+  my $self = shift;
  11
+
  12
+  my $user_rs = $self->schema->resultset('User');
  13
+  my $list_rs = $self->schema->resultset('List');
  14
+  my $user = $user_rs->create({
  15
+    username => 'user',
  16
+    password => 'pass',
  17
+    email    => 'user@example.com',
  18
+  });
  19
+
  20
+  my $list = $user->add_to_lists({
  21
+    title => 'test list',
  22
+    slug  => 'test',
  23
+  });
  24
+
  25
+  ok($list, 'Got a list');
  26
+  isa_ok($list, 'Lystyng::Schema::Result::List');
  27
+
  28
+  is(scalar $user->lists, 1, 'User owns one list');
  29
+
  30
+  my ($list2) = $list_rs->search({
  31
+    user => $user->id,
  32
+    slug => 'test',
  33
+  });
  34
+
  35
+  ok($list2, 'Got a list from the database...');
  36
+  is($list2->title, 'test list', '... and it has the correct title');
  37
+
  38
+  $list_rs->delete;
  39
+  $user_rs->delete;
  40
+}
  41
+
  42
+1;
1  t/tests.t
@@ -4,5 +4,6 @@ use lib 't';
4 4
 use Test::Class;
5 5
 use Test::Lystyng::Schema;
6 6
 use Test::Lystyng::Schema::Result::User;
  7
+use Test::Lystyng::Schema::Result::List;
7 8
 
8 9
 Test::Class->runtests;

0 notes on commit f9429d5

Please sign in to comment.
Something went wrong with that request. Please try again.