Add new test for basic sanity
[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 ( $dsn, $user, $pass )
14     = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ };
15
16 plan skip_all => <<'EOM' unless $dsn && $user;
17 Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test
18 ( NOTE: This test drops and creates some tables.')
19 EOM
20
21 my $schema = NoSequence->connect( $dsn, $user, $pass );
22 $schema->storage->dbh->{Warn} = 0;
23 $schema->storage->ensure_connected;
24 $schema->storage->_use_insert_returning(0);
25
26 my $dir = "t/sql";    # tempdir(CLEANUP => 0);
27 $schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir );
28 $schema->deploy( { add_drop_table => 1, add_drop_view => 1 } );
29
30 isa_ok(
31     $schema->source('Mesclun'),
32     'DBIx::Class::ResultSource::View',
33     "My MTI class also"
34 );
35
36 my ( $bowl_of_salad, $bowl_of_salad1 );
37
38 lives_ok {
39     $bowl_of_salad = $schema->resultset('Mesclun')
40         ->create( { acidity => 4, spiciness => '10', fresh => 0 } );
41 }
42 "I can call a create on a view mesclun";
43
44 lives_ok {
45     $bowl_of_salad1 = $schema->resultset('Salad')->create( { fresh => 1 } );
46 }
47 "I can do it for the other view, too";
48