diff --git a/0001-Skip-TestCloseBadConn-if-PGHOST-is-a-Unix-domain-soc.patch b/0001-Skip-TestCloseBadConn-if-PGHOST-is-a-Unix-domain-soc.patch new file mode 100644 index 0000000..120659f --- /dev/null +++ b/0001-Skip-TestCloseBadConn-if-PGHOST-is-a-Unix-domain-soc.patch @@ -0,0 +1,27 @@ +From d797f685f5c3ec0e65914cad41ab4ac5dc0c6fad Mon Sep 17 00:00:00 2001 +From: Elliott Sales de Andrade +Date: Mon, 17 Feb 2020 04:47:11 -0500 +Subject: [PATCH] Skip TestCloseBadConn if PGHOST is a Unix-domain socket. + +Signed-off-by: Elliott Sales de Andrade +--- + conn_test.go | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/conn_test.go b/conn_test.go +index 0d25c95..4ba86d4 100644 +--- a/conn_test.go ++++ b/conn_test.go +@@ -728,6 +728,9 @@ func TestCloseBadConn(t *testing.T) { + if host == "" { + host = "localhost" + } ++ if host[0] == '/' { ++ t.Skip("cannot test bad connection close with a Unix-domain PGHOST") ++ } + port := os.Getenv("PGPORT") + if port == "" { + port = "5432" +-- +2.21.1 + diff --git a/905.patch b/905.patch new file mode 100644 index 0000000..e7b4003 --- /dev/null +++ b/905.patch @@ -0,0 +1,33 @@ +From 16412e513ac51545006ae65e7cc081121edcd0ec Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Alfonso=20Subiotto=20Marqu=C3=A9s?= + +Date: Fri, 11 Oct 2019 09:44:50 -0400 +Subject: [PATCH] Make TestCloseBadConn observe PGHOST and PGPORT + +The test would previously attempt to dial localhost:5432 regardless of +the environment variables observed by all other tests (indirectly). +--- + conn_test.go | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/conn_test.go b/conn_test.go +index dba728fe..0d25c955 100644 +--- a/conn_test.go ++++ b/conn_test.go +@@ -724,7 +724,15 @@ func TestBadConn(t *testing.T) { + // TestCloseBadConn tests that the underlying connection can be closed with + // Close after an error. + func TestCloseBadConn(t *testing.T) { +- nc, err := net.Dial("tcp", "localhost:5432") ++ host := os.Getenv("PGHOST") ++ if host == "" { ++ host = "localhost" ++ } ++ port := os.Getenv("PGPORT") ++ if port == "" { ++ port = "5432" ++ } ++ nc, err := net.Dial("tcp", host+":"+port) + if err != nil { + t.Fatal(err) + } diff --git a/golang-github-lib-pq.spec b/golang-github-lib-pq.spec index 34ce975..88d8827 100644 --- a/golang-github-lib-pq.spec +++ b/golang-github-lib-pq.spec @@ -1,6 +1,5 @@ # Generated by go2rpm -# Needs network -%bcond_with check +%bcond_without check # https://github.com/lib/pq %global goipath github.com/lib/pq @@ -17,7 +16,7 @@ A pure Go postgres driver for Go's database/sql package} %global gosupfiles glide.lock glide.yaml Name: %{goname} -Release: 3%{?dist} +Release: 4%{?dist} Summary: Pure Go postgres driver for database/sql License: MIT @@ -25,6 +24,12 @@ URL: %{gourl} Source0: %{gosource} Source1: glide.yaml Source2: glide.lock +# Make TestCloseBadConn observe PGHOST and PGPORT +Patch0001: https://github.com/lib/pq/pull/905.patch +# https://github.com/lib/pq/pull/943 +Patch0002: 0001-Skip-TestCloseBadConn-if-PGHOST-is-a-Unix-domain-soc.patch + +BuildRequires: postgresql-test-rpm-macros %description %{common_description} @@ -33,6 +38,8 @@ Source2: glide.lock %prep %goprep +%patch0001 -p1 +%patch0002 -p1 cp %{S:1} %{S:2} . mv certs/README certs-README @@ -41,12 +48,17 @@ mv certs/README certs-README %if %{with check} %check +%postgresql_tests_run +export PGUSER=$(id -un) PGPASSWORD=$(id -un) PGDATABASE=$(id -un) %gocheck %endif %gopkgfiles %changelog +* Mon Feb 17 2020 Elliott Sales de Andrade - 1.1.1-4 +- Enable tests + * Wed Jan 29 2020 Fedora Release Engineering - 1.1.1-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild