#!perl
use strict;
use warnings;

use Test::More;
use DBIx::Fast;

# Legacy connect smoke test; honors the unified DBIX_FAST_TEST_PG gate
# (DBIX_FAST_TEST_PGDB kept for backwards compatibility).
my $pg_dsn = $ENV{DBIX_FAST_TEST_PGDB} // $ENV{DBIX_FAST_TEST_PG};
plan skip_all => "DBIX_FAST_TEST_PG not set" unless $pg_dsn;

# No version floor: DBD::Pg's v-string $VERSION (v3.20.2) makes a plain
# "use DBD::Pg 3.18" read as v3.180.0 and fail on newer releases.
eval { require DBD::Pg; 1 }
  or plan skip_all => "DBD::Pg required";

my $db = eval { DBIx::Fast->new( dsn => $pg_dsn ) };
plan skip_all => "Cannot connect to PostgreSQL ($pg_dsn): $@" if $@ or !$db;

isa_ok( $db, 'DBIx::Fast' );
is( $db->dbd, 'Pg', 'driver resolved to Pg' );
ok( $db->db->dbh->ping, 'live connection established' );
is( $db->val('SELECT 1'), 1, 'roundtrip query works' );

done_testing();
