Description: Use system instance for PostgreSQL tests
Author: Jérôme Charaoui <jerome@riseup.net>
Last-Update: Tue, 01 Apr 2025 16:20:26 -0400
Forwarded: not-needed

Index: next-jdbc-clojure/test/next/jdbc/test_fixtures.clj
===================================================================
--- next-jdbc-clojure.orig/test/next/jdbc/test_fixtures.clj
+++ next-jdbc-clojure/test/next/jdbc/test_fixtures.clj
@@ -5,8 +5,7 @@
   (:require [clojure.string :as str]
             [next.jdbc :as jdbc]
             [next.jdbc.prepare :as prep]
-            [next.jdbc.sql :as sql])
-  (:import (io.zonky.test.db.postgres.embedded EmbeddedPostgres)))
+            [next.jdbc.sql :as sql]))
 
 (set! *warn-on-reflection* true)
 
@@ -21,11 +20,11 @@
 (def ^:private test-sqlite {:dbtype "sqlite" :dbname "clojure_test_sqlite"})
 
 ;; this is just a dummy db-spec -- it's handled in with-test-db below
-(def ^:private test-postgres-map {:dbtype "embedded-postgres" :dbname "clojure_test"})
+(def ^:private test-postgres-map {:dbtype "postgres" :dbname "clojure_test" :port (System/getenv "PGPORT")})
 (def ^:private test-postgres
   (when-not (System/getenv "NEXT_JDBC_NO_POSTGRES") test-postgres-map))
 ;; it takes a while to spin up so we kick it off at startup
-(defonce embedded-pg (when test-postgres (future (EmbeddedPostgres/start))))
+;;(defonce embedded-pg (when test-postgres (future (EmbeddedPostgres/start))))
 
 (def ^:private test-mysql-map
   (merge (if (System/getenv "NEXT_JDBC_TEST_MARIADB")
@@ -84,7 +83,7 @@
 
 (defn mysql? [] (#{"mariadb" "mysql"} (:dbtype @test-db-spec)))
 
-(defn postgres? [] (= "embedded-postgres" (:dbtype @test-db-spec)))
+(defn postgres? [] (= "postgres" (:dbtype @test-db-spec)))
 
 (defn sqlite? [] (= "sqlite" (:dbtype @test-db-spec)))
 
@@ -135,10 +134,7 @@
   [t]
   (doseq [db test-db-specs]
     (reset! test-db-spec db)
-    (if (= "embedded-postgres" (:dbtype db))
-      (reset! test-datasource
-              (.getPostgresDatabase ^EmbeddedPostgres @embedded-pg))
-      (reset! test-datasource (jdbc/get-datasource db)))
+    (reset! test-datasource (jdbc/get-datasource db))
     (let [fruit (if (mysql?) "fruit" "FRUIT") ; MySQL is case sensitive!
           btest (if (mysql?) "btest" "BTEST")
           auto-inc-pk
