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