Commit | Line | Data |
2c296bdb |
1 | use strict; |
2 | use warnings; |
3 | use lib 't/lib'; |
0906c32b |
4 | use Test::More tests => 4; |
2c296bdb |
5 | use Test::Exception; |
4eaa25b5 |
6 | use CafeInsertion; |
2c296bdb |
7 | |
8 | BEGIN { |
ebcd7e95 |
9 | $ENV{DBIC_TRACE} = 0; |
2c296bdb |
10 | } |
4eaa25b5 |
11 | |
32098147 |
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 | |
4eaa25b5 |
19 | my $schema = CafeInsertion->connect( $dsn, $user, $pass ); |
2c296bdb |
20 | $schema->storage->ensure_connected; |
21 | $schema->storage->_use_insert_returning(0); |
c965b761 |
22 | $schema->storage->dbh->{Warn} = 0; |
ebcd7e95 |
23 | |
24 | my $dir = "t/sql"; # tempdir(CLEANUP => 0); |
25 | $schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ); |
26 | $schema->deploy( { add_drop_table => 1, add_drop_view => 1 } ); |
27 | |
2c296bdb |
28 | isa_ok( |
29 | $schema->source('Sumatra'), |
30 | 'DBIx::Class::ResultSource::View', |
31 | "My MTI class also" |
32 | ); |
33 | |
34 | my ( $drink, $drink1 ); |
35 | |
36 | lives_ok { |
c965b761 |
37 | $drink = $schema->resultset('Sumatra')->create( |
38 | { sweetness => 4, |
39 | fat_free => 1, |
40 | aroma => 'earthy', |
41 | flavor => 'great' |
42 | } |
43 | ); |
2c296bdb |
44 | } |
45 | "I can call a create on a view sumatra"; |
46 | |
47 | lives_ok { |
48 | $drink1 = $schema->resultset('Coffee')->create( { flavor => 'aaight', } ); |
49 | } |
50 | "I can do it for the other view, too"; |
e96b2eeb |
51 | |
3365fc70 |
52 | my $sqlt_object = $schema->{sqlt}; |
3365fc70 |
53 | is_deeply( |
54 | [ map { $_->name } $sqlt_object->get_views ], |
55 | [ qw/ |
c965b761 |
56 | coffee |
3365fc70 |
57 | sumatra |
58 | / |
59 | ], |
60 | "SQLT view order triumphantly matches our order." |
61 | ); |
62 | |