Mojo-Pg-Che

 view release on metacpan or  search on metacpan

t/07-base-crud.t  view on Meta::CPAN

my ($dsn, $user, $pw) = split m|[/]|, $ENV{TEST_PG};

use Mojo::IOLoop;
use Mojo::Pg::Che;

# Isolate tests
#~ my $pg = Mojo::Pg::Che->new($ENV{TEST_ONLINE})->search_path(['mojo_crud_test']);
my $pg = Mojo::Pg::Che->connect($dsn, $user, $pw, {PrintWarn => 0,}, search_path=>['mojo_crud_test'])
  ->pg;#max_connections=>20
#~ is_deeply $pg->options, {}, 'right options';
$pg->db->query('drop schema if exists mojo_crud_test cascade');
$pg->db->query('create schema mojo_crud_test');

my $db = $pg->db;
$db->query(
  'create table if not exists crud_test (
     id   serial primary key,
     name text
   )'
);

t/07-base-crud.t  view on Meta::CPAN

);
$db->insert('crud_test4', {test1 => 'hello'});
$db->insert('crud_test5', {test2 => 'world'});
is_deeply $db->select(['crud_test4', ['crud_test5', id => 'id']],
  ['crud_test4.id', 'test1', 'test2', ['crud_test4.test1' => 'test3']])
  ->hashes->to_array,
  [{id => 1, test1 => 'hello', test2 => 'world', test3 => 'hello'}],
  'right structure';

# Clean up once we are done
$pg->db->query('drop schema mojo_crud_test cascade');

done_testing();



( run in 0.609 second using v1.01-cache-2.11-cpan-49f99fa48dc )