Add a test lib and failing test for no explicit sequence declaration
[dbsrgits/DBIx-Class-ResultSource-MultipleTableInheritance.git] / t / 04no_sequence_defined.t
1 use strict;
2 use warnings;
3 use lib 't/lib';
4 use Test::More qw(no_plan);
5 use Test::Exception;
6 use Devel::Dwarn;
7
8 BEGIN {
9     use_ok 'NoSequence';
10     $ENV{DBIC_TRACE} = 0;
11 }
12
13 my $schema = NoSequence->connect( 'dbi:Pg:dbname=test', 'postgres', '' );
14 $schema->storage->dbh->{Warn} = 0;
15 $schema->storage->ensure_connected;
16 $schema->storage->_use_insert_returning(0);
17
18 my $dir = "t/sql";    # tempdir(CLEANUP => 0);
19 $schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir );
20 $schema->deploy( { add_drop_table => 1, add_drop_view => 1 } );
21
22 isa_ok(
23     $schema->source('Mesclun'),
24     'DBIx::Class::ResultSource::View',
25     "My MTI class also"
26 );
27
28 my ( $bowl_of_salad, $bowl_of_salad1 );
29
30 lives_ok {
31     $bowl_of_salad = $schema->resultset('Mesclun')
32         ->create( { acidity => 4, spiciness => '10', fresh => 0 } );
33 }
34 "I can call a create on a view mesclun";
35
36 lives_ok {
37     $bowl_of_salad1 = $schema->resultset('Salad')->create( { fresh => 1 } );
38 }
39 "I can do it for the other view, too";
40
41