5 use SGN::Test 'with_test_level';
7 $SIG{__DIE__} = \&Carp::confess;
11 my $c = SGN::Context->new;
13 #### test dbh() method
14 can_ok( $c->dbc, 'dbh', 'run','txn' );
15 can_ok( $c->dbc->dbh, 'selectall_arrayref', 'prepare', 'ping' );
17 ok( $c->dbc->dbh->ping, 'dbh looks live' );
20 $c->dbc('nonexistent connection profile');
21 } qr/not defined/, 'throws for nonexistent connection profile';
23 like( $c->dbc->dbh->{private_search_path_string},
25 'private_search_path has something in it',
28 # test dbic_schema method
30 my $schema = $c->dbic_schema('Test::Schema');
31 can_ok( $schema, 'resultset', 'storage' );
32 ok( $schema->storage->dbh->ping, 'dbic storage is connected' );
33 is( search_path( $schema->storage->dbh), search_path( $c->dbc->dbh ), 'schema and dbc should have same search path' );
35 # test tempfile method
36 with_test_level( local => sub {
37 my ($tempfile, $temp_uri) =
38 $c->tempfile( TEMPLATE => [ 'foobar','noggin-XXXXX' ],
41 can_ok( $tempfile, 'filename', 'print' );
42 can_ok( $temp_uri, 'path' );
43 unlike( $temp_uri, qr/X{5}/, 'temp_uri got its Xs replaced' );
44 unlike( $temp_uri, qr/X{5}/, 'temp_uri got its Xs replaced' );
45 like( "$tempfile", qr/\.foo$/, 'tempfile name has suffix' );
46 like( "$temp_uri", qr/\.foo$/, 'tempfile uri has suffix' );
54 my ($sp) = $dbh->selectrow_array('show search_path');
60 use base 'DBIx::Class::Schema';