Remove non-functional part of ::Storage::DBI::Sybase::_ping
[dbsrgits/DBIx-Class.git] / t / icdt / engine_specific / msaccess.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
54a9a088 2use DBIx::Class::Optional::Dependencies -skip_all_without => qw( ic_dt _rdbms_msaccess_common );
2baba3d9 3
726c8f65 4use strict;
5use warnings;
6
7use Test::More;
726c8f65 8use Try::Tiny;
bbf6a9a5 9use DBIx::Class::_Util 'scope_guard';
c0329273 10
726c8f65 11use DBICTest;
12
2baba3d9 13my @tdeps = qw( test_rdbms_msaccess_odbc test_rdbms_msaccess_ado );
14plan skip_all => 'Test needs ' . (join ' OR ', map
15 { "[ @{[ DBIx::Class::Optional::Dependencies->req_missing_for( $_ ) ]} ]" }
16 @tdeps
17) unless scalar grep
18 { DBIx::Class::Optional::Dependencies->req_ok_for( $_ ) }
19 @tdeps
20;
21
726c8f65 22my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSACCESS_ODBC_${_}" } qw/DSN USER PASS/};
23my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSACCESS_ADO_${_}" } qw/DSN USER PASS/};
24
726c8f65 25my @connect_info = (
26 [ $dsn, $user || '', $pass || '' ],
27 [ $dsn2, $user2 || '', $pass2 || '' ],
28);
29
726c8f65 30for my $connect_info (@connect_info) {
31 my ($dsn, $user, $pass) = @$connect_info;
32
33 next unless $dsn;
34
6892eb09 35 my $schema = DBICTest::Schema->connect($dsn, $user, $pass, {
726c8f65 36 on_connect_call => 'datetime_setup',
37 quote_names => 1,
38 });
39
bbf6a9a5 40 my $guard = scope_guard { cleanup($schema) };
726c8f65 41
42 try { local $^W = 0; $schema->storage->dbh->do('DROP TABLE track') };
43 $schema->storage->dbh->do(<<"SQL");
44CREATE TABLE track (
45 trackid AUTOINCREMENT PRIMARY KEY,
46 cd INT,
47 [position] INT,
48 last_updated_at DATETIME
49)
50SQL
51
52 ok(my $dt = DateTime->new({
53 year => 2004,
54 month => 8,
55 day => 21,
56 hour => 14,
57 minute => 36,
58 second => 48,
59 }));
60
61 ok(my $row = $schema->resultset('Track')->create({
62 last_updated_at => $dt,
63 cd => 1
64 }));
65 ok($row = $schema->resultset('Track')
66 ->search({ trackid => $row->trackid }, { select => ['last_updated_at'] })
67 ->first
68 );
69 is($row->last_updated_at, $dt, "DATETIME roundtrip" );
70}
71
72done_testing;
73
74# clean up our mess
75sub cleanup {
6892eb09 76 my $schema = shift;
726c8f65 77 # have to reconnect to drop a table that's in use
78 if (my $storage = eval { $schema->storage }) {
79 local $^W = 0;
80 $storage->disconnect;
81 $storage->dbh->do('DROP TABLE track');
82 }
83}