Improve SQLT::Parser warning messages (build further upon e089c417)
[dbsrgits/DBIx-Class.git] / t / inflate / datetime_pg.t
CommitLineData
40f75181 1use strict;
2use warnings;
3
4use Test::More;
49bceca3 5use Test::Warn;
199fbc45 6use DBIx::Class::Optional::Dependencies ();
40f75181 7use lib qw(t/lib);
8use DBICTest;
9
68de9438 10plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_pg')
11 unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_pg');
12
052a832c 13DBICTest::Schema->load_classes('EventTZPg');
40f75181 14
40f75181 15my $schema = DBICTest->init_schema();
16
49bceca3 17warnings_are {
40f75181 18 my $event = $schema->resultset("EventTZPg")->find(1);
19 $event->update({created_on => '2009-01-15 17:00:00+00'});
20 $event->discard_changes;
21 isa_ok($event->created_on, "DateTime") or diag $event->created_on;
22 is($event->created_on->time_zone->name, "America/Chicago", "Timezone changed");
23 # Time zone difference -> -6hours
24 is($event->created_on->iso8601, "2009-01-15T11:00:00", "Time with TZ correct");
65b386df 25
26# test 'timestamp without time zone'
27 my $dt = DateTime->from_epoch(epoch => time);
28 $dt->set_nanosecond(int 500_000_000);
29 $event->update({ts_without_tz => $dt});
30 $event->discard_changes;
31 isa_ok($event->ts_without_tz, "DateTime") or diag $event->created_on;
32 is($event->ts_without_tz, $dt, 'timestamp without time zone inflation');
33 is($event->ts_without_tz->microsecond, $dt->microsecond,
34 'timestamp without time zone microseconds survived');
49bceca3 35} [], 'No warnings during DT manipulations';
68de9438 36
37done_testing;