add074ee1ecc5263fa2231a1e743b4d5ca2cfd30
[dbsrgits/DBIx-Class-ResultSource-MultipleTableInheritance.git] / t / 03insert.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 CafeInsertion;
7
8 BEGIN {
9     $ENV{DBIC_TRACE} = 0;
10 }
11
12 my ( $dsn, $user, $pass )
13     = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ };
14 plan skip_all => <<'EOM' unless $dsn && $user;
15 Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test
16 ( NOTE: This test drops and creates some tables.')
17 EOM
18
19 my $schema = CafeInsertion->connect( $dsn, $user, $pass );
20 $schema->storage->ensure_connected;
21 $schema->storage->_use_insert_returning(0);
22
23 my $dir = "t/sql";    # tempdir(CLEANUP => 0);
24 $schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir );
25 $schema->deploy( { add_drop_table => 1, add_drop_view => 1 } );
26
27 isa_ok(
28     $schema->source('Sumatra'),
29     'DBIx::Class::ResultSource::View',
30     "My MTI class also"
31 );
32
33 my ( $drink, $drink1 );
34
35 lives_ok {
36     $drink = $schema->resultset('Sumatra')
37         ->create( { sweetness => 4, aroma => 'earthy', flavor => 'great' } );
38 }
39 "I can call a create on a view sumatra";
40
41 lives_ok {
42     $drink1 = $schema->resultset('Coffee')->create( { flavor => 'aaight', } );
43 }
44 "I can do it for the other view, too";
45