Add import-time-skip support to OptDeps, switch most tests over to that
[dbsrgits/DBIx-Class.git] / t / inflate / datetime_pg.t
CommitLineData
cb551b07 1use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt_pg';
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
40f75181 13my $schema = DBICTest->init_schema();
14
49bceca3 15warnings_are {
40f75181 16 my $event = $schema->resultset("EventTZPg")->find(1);
17 $event->update({created_on => '2009-01-15 17:00:00+00'});
18 $event->discard_changes;
19 isa_ok($event->created_on, "DateTime") or diag $event->created_on;
20 is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
21 # Time zone difference -> -6hours
22 is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
65b386df 23
24# test 'timestamp without time zone'
25 my $dt = DateTime->from_epoch(epoch => time);
26 $dt->set_nanosecond(int 500_000_000);
27 $event->update({ts_without_tz => $dt});
28 $event->discard_changes;
29 isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
30 is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
31 is($event->ts_without_tz->microsecond, $dt->microsecond,
32 'timestamp without time zone microseconds survived');
49bceca3 33} [], 'No warnings during DT manipulations';
68de9438 34
35done_testing;