Re: How can I include sql file in pgTAP unittest? - Mailing list pgsql-general

From Adrian Klaver
Subject Re: How can I include sql file in pgTAP unittest?
Date
Msg-id 9d279104-44f0-417d-7448-8da4f304eecd@aklaver.com
Whole thread Raw
In response to Re: How can I include sql file in pgTAP unittest?  (Stéphane Klein <contact@stephane-klein.info>)
List pgsql-general
On 03/02/2018 06:46 AM, Stéphane Klein wrote:


> 
> Sorry, it is not kea but db2 in my example. I did a mistake when I 
> replace the db name in my example.
> 
> You need to read:
> 
>    CREATE EXTENSION IF NOT EXISTS postgres_fdw;
>    DROP SERVER IF EXISTS db2 CASCADE;
>    CREATE SERVER db2 FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 
> 'db2', dbname 'db2');
>    CREATE USER MAPPING FOR USER SERVER db2 OPTIONS (user 'db2', password 
> 'password');
> 
>    CREATE SCHEMA IF NOT EXISTS db2;
> 
>    IMPORT FOREIGN SCHEMA public FROM SERVER db2 INTO db2;

I don't know much about pgTap, but my first instinct would be to change:

BEGIN;
   SELECT plan(1);

   \i /test/init.sql

   SELECT ok(
     (SELECT COUNT(host_id) FROM db2.hosts) = 1,
     'foobar'
   );

to:


BEGIN;

   \i /test/init.sql

   SELECT plan(1);

   SELECT ok(
     (SELECT COUNT(host_id) FROM db2.hosts) = 1,
     'foobar'
   );


-- 
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: jsonb_array_length: ERROR: 22023: cannot get array length of ascalar
Next
From: "David G. Johnston"
Date:
Subject: Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar