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