Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added (simple) test for user creation.

  • Loading branch information...
commit 6e7ea9fcba134b2b636364571d60bd0989f2a9a1 1 parent 9c37b98
@davorg authored
Showing with 48 additions and 0 deletions.
  1. +47 −0 t/Test/Lystyng/Schema/Result/User.pm
  2. +1 −0  t/tests.t
View
47 t/Test/Lystyng/Schema/Result/User.pm
@@ -0,0 +1,47 @@
+package Test::Lystyng::Schema::Result::User;
+
+use base qw(Test::Class);
+use Test::More;
+use Moose;
+
+use Lystyng::Schema;
+
+has schema => (
+ is => 'rw',
+ isa => 'Lystyng::Schema',
+ lazy => 1,
+ builder => '_build_schema',
+);
+
+sub _build_schema {
+ my @errors;
+ foreach (qw[LYSTYNG_DB_SERVER LYSTYNG_DB_NAME
+ LYSTYNG_DB_USER LYSTYNG_DB_PASS]) {
+ push @errors, $_ unless defined $ENV{$_};
+ }
+
+ if (@errors) {
+ BAIL_OUT("Missing connection info: @errors");
+ }
+
+ return Lystyng::Schema->connect(
+ "dbi:mysql:hostname=$ENV{LYSTYNG_DB_SERVER};database=$ENV{LYSTYNG_DB_NAME}",
+ $ENV{LYSTYNG_DB_USER}, $ENV{LYSTYNG_DB_PASS}
+ );
+}
+
+sub create : Tests {
+ my $self = shift;
+
+ my $user_rs = $self->schema->resultset('User');
+ my $user = $user_rs->create({
+ username => 'user',
+ password => 'pass',
+ email => 'user@example.com',
+ });
+
+ ok($user, 'Got a user');
+ isa_ok($user, 'Lystyng::Schema::Result::User');
+}
+
+1;
View
1  t/tests.t
@@ -3,5 +3,6 @@
use lib 't';
use Test::Class;
use Test::Lystyng::Schema;
+use Test::Lystyng::Schema::Result::User;
Test::Class->runtests;
Please sign in to comment.
Something went wrong with that request. Please try again.