Skip to content

Instantly share code, notes, and snippets.

@domm
Created July 1, 2010 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domm/459819 to your computer and use it in GitHub Desktop.
Save domm/459819 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use strict;
use warnings;
use Scalar::Util qw(refaddr);
use Test::More;
use Test::Exception;
use KiokuDB;
BEGIN {
plan skip_all => "DBD::SQLite are required" unless eval { require DBI; require DBD::SQLite };
}
{
package MyApp::DB::Result::Foo;
use base qw(DBIx::Class::Core);
__PACKAGE__->load_components(qw(KiokuDB));
__PACKAGE__->table('foo');
__PACKAGE__->add_columns(qw(id name object));
__PACKAGE__->set_primary_key('id');
__PACKAGE__->kiokudb_column('object');
package MyApp::DB;
use base qw(DBIx::Class::Schema);
__PACKAGE__->load_components(qw(Schema::KiokuDB));
__PACKAGE__->register_class( Foo => qw(MyApp::DB::Result::Foo));
package Foo;
use Moose;
has name => ( isa => "Str", is => "ro" );
has obj => ( isa => "Object", is => "ro", weak_ref => 1 );
__PACKAGE__->meta->make_immutable;
}
my $schema = MyApp::DB->connect('dbi:SQLite:dbname=:memory:');
lives_ok {
$schema->resultset('Foo')->create({name=>'foo'});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment