Release 0.02
[dbsrgits/DBIx-Class-ResultSource-MultipleTableInheritance.git] / t / 04no_sequence_defined.t
CommitLineData
70955816 1use strict;
2use warnings;
3use lib 't/lib';
0906c32b 4use Test::More tests => 5;
70955816 5use Test::Exception;
4eaa25b5 6use NoSequenceSalad;
70955816 7
8BEGIN {
d8c2caa7 9 $ENV{DBIC_TRACE} = 0;
70955816 10}
32098147 11my ( $dsn, $user, $pass )
12 = @ENV{ map {"DBICTEST_PG_${_}"} qw/DSN USER PASS/ };
13
14plan skip_all => <<'EOM' unless $dsn && $user;
15Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test
16( NOTE: This test drops and creates some tables.')
17EOM
18
4eaa25b5 19my $schema = NoSequenceSalad->connect( $dsn, $user, $pass );
70955816 20$schema->storage->ensure_connected;
d8c2caa7 21$schema->storage->dbh->{Warn} = 0;
70955816 22$schema->storage->_use_insert_returning(0);
23
24my $dir = "t/sql"; # tempdir(CLEANUP => 0);
25$schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir );
d8c2caa7 26
27lives_ok { $schema->deploy( { add_drop_table => 1, add_drop_view => 1 } ) }
28"I can deploy the schema";
70955816 29
30isa_ok(
31 $schema->source('Mesclun'),
32 'DBIx::Class::ResultSource::View',
33 "My MTI class also"
34);
35
36my ( $bowl_of_salad, $bowl_of_salad1 );
37
38lives_ok {
39 $bowl_of_salad = $schema->resultset('Mesclun')
d8c2caa7 40 ->create( { acidity => 4, spiciness => '10', fresh => 0, } );
70955816 41}
42"I can call a create on a view mesclun";
43
44lives_ok {
45 $bowl_of_salad1 = $schema->resultset('Salad')->create( { fresh => 1 } );
46}
47"I can do it for the other view, too";
48
c965b761 49my $sqlt_object = $schema->{sqlt};
d8c2caa7 50
c965b761 51is_deeply(
52 [ map { $_->name } $sqlt_object->get_views ],
53 [ qw/
d8c2caa7 54 salad
c965b761 55 mesclun
56 /
57 ],
58 "SQLT view order triumphantly matches our order."
59);