packages feed

pqi-conformance 1.0.6.0 → 1.0.7.0

raw patch · 4 files changed

+54/−1 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+# v1.0.7.0++## Non-breaking++- Added a `connectdb` spec covering a `postgresql://` URI whose host segment is a percent-encoded Unix-socket directory, checked via the parsed host rather than the failure message. Found `pqi-native`'s URI parser never runs the host segment through percent-decoding, unlike every sibling component.+ # v1.0.6.0  ## Non-breaking
pqi-conformance.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: pqi-conformance-version: 1.0.6.0+version: 1.0.7.0 category: Database, PostgreSQL, Testing synopsis: Differential conformance tests for pqi adapters description:@@ -95,6 +95,7 @@     Pqi.Conformance.Operation.CmdTuples     Pqi.Conformance.Operation.Connectdb     Pqi.Conformance.Operation.Connectdb.Rejection+    Pqi.Conformance.Operation.Connectdb.UnixSocketUri     Pqi.Conformance.Operation.ConnectionNeedsPassword     Pqi.Conformance.Operation.ConnectionUsedPassword     Pqi.Conformance.Operation.ConnectPoll
src/library/Pqi/Conformance/Operation/Connectdb.hs view
@@ -15,6 +15,7 @@ import Pqi.Conformance.Harness import Pqi.Conformance.Observation import qualified Pqi.Conformance.Operation.Connectdb.Rejection as Rejection+import qualified Pqi.Conformance.Operation.Connectdb.UnixSocketUri as UnixSocketUri import Pqi.Conformance.Prelude import qualified Pqi.Conformance.Reference as Reference import Test.Hspec@@ -23,6 +24,7 @@ spec :: Pqi.Adapter -> SpecWith ByteString spec adapter = do   Rejection.spec adapter+  UnixSocketUri.spec adapter    describe "connectdb" do     it "opens a usable connection" \conninfo ->
+ src/library/Pqi/Conformance/Operation/Connectdb/UnixSocketUri.hs view
@@ -0,0 +1,44 @@+-- | Coverage for a @postgresql:\/\/@ URI conninfo whose host segment is a+-- percent-encoded Unix-domain socket directory (e.g. @%2ftmp%2fsome-dir@),+-- per PostgreSQL's own URI convention:+-- <https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS>.+--+-- Found in @pqi-native@: @parseUri@'s host branch is never run through+-- @pctDecode@, unlike every sibling component (user, password, database,+-- query params), which all are. The candidate therefore treats the+-- still-percent-encoded string as a literal hostname to resolve via DNS,+-- instead of decoding it into the filesystem socket-directory path the URI+-- names.+--+-- This is deliberately checked via 'Pqi.host' rather than+-- 'Pqi.errorMessage': both adapters fail to connect either way (there is no+-- such socket directory), but their failure text is produced by unrelated,+-- adapter-specific machinery (DNS resolution vs. a filesystem check) and+-- isn't expected to match byte-for-byte. What must match is the host each+-- adapter parsed out of the conninfo, which is deterministic and+-- OS\/locale-independent.+module Pqi.Conformance.Operation.Connectdb.UnixSocketUri+  ( spec,+  )+where++import qualified Pqi+import Pqi.Conformance.Harness+import Pqi.Conformance.Prelude+import Test.Hspec++spec :: Pqi.Adapter -> SpecWith ByteString+spec adapter =+  describe "connectdb" do+    describe "a URI conninfo with a percent-encoded Unix-socket host" do+      it "decodes the host the same way the reference does" \_ ->+        differentialConnect adapter conninfo \adapter' conninfo' -> do+          connection <- Pqi.connectdb adapter' conninfo'+          observedHost <- Pqi.host connection+          Pqi.finish connection+          pure observedHost+  where+    -- Points at a socket directory that doesn't exist: this test is only+    -- about how the host segment is parsed, not about a real connection+    -- succeeding.+    conninfo = "postgresql://%2ftmp%2fpqi-conformance-nonexistent-socket-dir"