Fix failed tests for PostgreSQL-10.

This commit is contained in:
Jun Aruga 2017-12-08 12:06:50 +01:00
parent 04b1c7055c
commit 01ad574b30
2 changed files with 77 additions and 7 deletions

View File

@ -0,0 +1,57 @@
From 55ca6dd8c1e0925f617b8f9e9042cbea01cf0eb8 Mon Sep 17 00:00:00 2001
From: Lars Kanis <kanis@comcard.de>
Date: Mon, 23 Oct 2017 13:02:45 +0200
Subject: [PATCH] Adjust tests for PostgreSQL-10
---
spec/helpers.rb | 2 +-
spec/pg/connection_spec.rb | 13 +++++++++----
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/spec/helpers.rb b/spec/helpers.rb
index d13df5e..e9856de 100755
--- a/spec/helpers.rb
+++ b/spec/helpers.rb
@@ -251,7 +251,7 @@ module PG::TestingHelpers
def check_for_lingering_connections( conn )
conn.exec( "SELECT * FROM pg_stat_activity" ) do |res|
- conns = res.find_all {|row| row['pid'].to_i != conn.backend_pid }
+ conns = res.find_all {|row| row['pid'].to_i != conn.backend_pid && ["client backend", nil].include?(row["backend_type"]) }
unless conns.empty?
puts "Lingering connections remain:"
conns.each do |row|
diff --git a/spec/pg/connection_spec.rb b/spec/pg/connection_spec.rb
index d055673..0924ca4 100755
--- a/spec/pg/connection_spec.rb
+++ b/spec/pg/connection_spec.rb
@@ -219,7 +219,7 @@ describe PG::Connection do
described_class.connect(@conninfo).finish
sleep 0.5
res = @conn.exec(%[SELECT COUNT(*) AS n FROM pg_stat_activity
- WHERE usename IS NOT NULL])
+ WHERE usename IS NOT NULL AND application_name != ''])
# there's still the global @conn, but should be no more
expect( res[0]['n'] ).to eq( '1' )
end
@@ -1524,9 +1524,14 @@ describe PG::Connection do
end
it "shouldn't type map params unless requested" do
- expect{
- @conn.exec_params( "SELECT $1", [5] )
- }.to raise_error(PG::IndeterminateDatatype)
+ if @conn.server_version < 100000
+ expect{
+ @conn.exec_params( "SELECT $1", [5] )
+ }.to raise_error(PG::IndeterminateDatatype)
+ else
+ # PostgreSQL-10 maps to TEXT type (OID 25)
+ expect( @conn.exec_params( "SELECT $1", [5] ).ftype(0)).to eq(25)
+ end
end
it "should raise an error on invalid encoder to put_copy_data" do
--
2.14.3

View File

@ -3,7 +3,7 @@
Name: rubygem-%{gem_name}
Version: 0.21.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: A Ruby interface to the PostgreSQL RDBMS
# Upstream license clarification (https://bitbucket.org/ged/ruby-pg/issue/72/)
#
@ -16,6 +16,9 @@ Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
# Disable RPATH.
# https://bitbucket.org/ged/ruby-pg/issue/183
Patch0: rubygem-pg-0.17.1-remove-rpath.patch
# Fix tests for PostgreSQL-10.
# https://github.com/ged/ruby-pg/commit/fe24a71
Patch1: rubygem-pg-0.21.0-adjust-tests-for-postgresql-10.patch
BuildRequires: ruby(release)
BuildRequires: rubygems-devel
BuildRequires: ruby-devel
@ -78,16 +81,23 @@ for file in `find %{buildroot}%{gem_libdir} -type f -name "*.rb"`; do
done
# Fix spec shebangs.
# https://bitbucket.org/ged/ruby-pg/issue/74/
for file in `find %{buildroot}%{gem_instdir}/spec -type f ! -perm /a+x -name "*.rb"`; do
[ ! -z "`head -n 1 $file | grep \"^#!/\"`" ] \
&& sed -i -e 's/^#!\/usr\/bin\/env spec/#!\/usr\/bin\/env rspec/' $file \
&& chmod -v 755 $file
# https://bitbucket.org/ged/ruby-pg/issues/269/
for file in `find %{buildroot}%{gem_instdir}/spec -type f -name "*.rb"`; do
if [ ! -z "`head -n 1 $file | grep \"^#!/\"`" ]; then
sed -i '/^#!\/usr\/bin\/env/ d' $file
chmod -v 644 $file
fi
done
%check
pushd .%{gem_instdir}
rspec -I$(dirs +1)%{gem_extdir_mri} spec
cat "%{PATCH1}" | patch -p1
# Set LANG to prevent encoding warnings. See spec/pg/connection_spec.rb
# test case: "receives properly encoded messages in the notice callbacks".
# Set --verbose to show detail log by $VERBOSE.
# See https://github.com/ged/ruby-pg/blob/master/spec/helpers.rb $VERBOSE
LANG=en_US.UTF-8 ruby -S --verbose \
rspec -I$(dirs +1)%{gem_extdir_mri} -f d spec
popd
%files
@ -115,6 +125,9 @@ popd
%{gem_instdir}/spec
%changelog
* Fri Dec 08 2017 Jun Aruga <jaruga@redhat.com> - 0.21.0-2
- Fix failed tests for PostgreSQL-10.
* Thu Aug 17 2017 Vít Ondruch <vondruch@redhat.com> - 0.21.0-1
- Update to pg 1.21.0.