Fix failures and protect the suite from spurious VERSION-related warnings
[dbsrgits/DBIx-Class.git] / t / icdt / offline_pg.t
CommitLineData
54a9a088 1use DBIx::Class::Optional::Dependencies -skip_all_without => qw( ic_dt_pg );
cb551b07 2
40f75181 3use strict;
4use warnings;
5
6use Test::More;
49bceca3 7use Test::Warn;
40f75181 8use lib qw(t/lib);
9use DBICTest;
10
052a832c 11DBICTest::Schema->load_classes('EventTZPg');
40f75181 12
8548e45c 13{
14 my $s = DBICTest::Schema->connect('dbi:Pg:whatever');
15
16 ok (!$s->storage->_dbh, 'definitely not connected');
17
18 # Check that datetime_parser returns correctly before we explicitly connect.
19 my $store = ref $s->storage;
20 is($store, 'DBIx::Class::Storage::DBI', 'Started with generic storage');
21
22 my $parser = $s->storage->datetime_parser;
23 is( $parser, 'DateTime::Format::Pg', 'datetime_parser is as expected');
24
25 ok (!$s->storage->_dbh, 'still not connected');
26}
27
40f75181 28my $schema = DBICTest->init_schema();
29
da9346a0 30# this may generate warnings under certain CI flags, hence do it outside of
31# the warnings_are below
32my $dt = DateTime->new( year => 2000, time_zone => "America/Chicago" );
33
49bceca3 34warnings_are {
40f75181 35 my $event = $schema->resultset("EventTZPg")->find(1);
36 $event->update({created_on => '2009-01-15 17:00:00+00'});
37 $event->discard_changes;
38 isa_ok($event->created_on, "DateTime") or diag $event->created_on;
39 is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
40 # Time zone difference -> -6hours
41 is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
65b386df 42
43# test 'timestamp without time zone'
44 my $dt = DateTime->from_epoch(epoch => time);
45 $dt->set_nanosecond(int 500_000_000);
46 $event->update({ts_without_tz => $dt});
47 $event->discard_changes;
48 isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
49 is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
50 is($event->ts_without_tz->microsecond, $dt->microsecond,
51 'timestamp without time zone microseconds survived');
49bceca3 52} [], 'No warnings during DT manipulations';
68de9438 53
54done_testing;