Re: How can I include sql file in pgTAP unittest?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Stéphane Klein <contact(at)stephane-klein(dot)info>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: How can I include sql file in pgTAP unittest?
Date: 2018-03-02 18:01:48
Message-ID: 9d279104-44f0-417d-7448-8da4f304eecd@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2018-03-02 18:04:02 Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar
Previous Message Adrian Klaver 2018-03-02 17:54:33 Re: jsonb_array_length: ERROR: 22023: cannot get array length of a scalar