Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erp0H-0003ny-LK for pgsql-general@arkaria.postgresql.org; Fri, 02 Mar 2018 18:01:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1erp0G-0007kr-Ca for pgsql-general@arkaria.postgresql.org; Fri, 02 Mar 2018 18:01:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erp0G-0007ki-4i for pgsql-general@lists.postgresql.org; Fri, 02 Mar 2018 18:01:56 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1erp0C-0008Fc-Vp for pgsql-general@lists.postgresql.org; Fri, 02 Mar 2018 18:01:55 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id AAEB12082E; Fri, 2 Mar 2018 13:01:49 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Fri, 02 Mar 2018 13:01:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=QGC1LSQ/ndXT7Dpo4m0vUNpLkpf6v XaRL0hvf7lPDsk=; b=IFsZ0yHVhQpSE4AMQb73qvbYa5WoSSeCCE+5m//YqchgG Wnnt/e6U6zAFaSlIXyc/RlVaXUO2H3w6+ZljImTc+kWMhyCTdo3iDGtxKpzbMYcS TlcVMKQpfn5Xxj4A2BfrgEbe++63uXeaa8lh4/qlk05P/wOWz4MH1SEYU6hifqka 5U+zO6TwW1DPKpYiHak2dUluvu6IqsLJbR0G9XE/cjzbGe9rkAwniYOSPZg/ObM0 +OEO0b7ZYM/d4GnKNe6PZy/Sp+ooQkFXMXHMAdnK7y59MONMLa06iGUWEyqXb8z5 tCOVq1X8ucc7rAJ4wvqzPmAjcnSrDB40/kSgG6gTQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=QGC1LS Q/ndXT7Dpo4m0vUNpLkpf6vXaRL0hvf7lPDsk=; b=YRu4tLDhWm9LcmqevaOLB3 yOk4XFJSOR7+KAFAwkC0KuWcBif0RmKqmc51RHxTJCKgASeH2jViba1f4oI6F+Ks V+pw8PTWXbcRyhH4hNtw8eAuWPaNA+zZMRI9g5UFBbVAxOST5evoVVRi/FbE7+sb 9MED/utZ/U3lXUIA4dHGmJLhYZPgZS5Etd3CxKIySgHgGha/KsimLu26wE+jXljf hazoN+VVjZJhZz2eL0eR+fIhlHCm+k7pv1mcM1Nj2SkzcpuNyCSRzIAjqTpUk83u 0nU6VfsK8adxUfSxecaAHjHFRRCcXYNUzVxLJ/3wqzgsDOfcwU56tyjJcQOgQceg == X-ME-Sender: Received: from [192.168.1.2] (71-35-123-124.tukw.qwest.net [71.35.123.124]) by mail.messagingengine.com (Postfix) with ESMTPA id 1C6237E6BC; Fri, 2 Mar 2018 13:01:49 -0500 (EST) Subject: Re: How can I include sql file in pgTAP unittest? To: =?UTF-8?Q?St=c3=a9phane_Klein?= Cc: pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: <9d279104-44f0-417d-7448-8da4f304eecd@aklaver.com> Date: Fri, 2 Mar 2018 10:01:48 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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