[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Use EphemeralPG for the tests.
From: |
Mathieu Othacehe |
Subject: |
branch master updated: Use EphemeralPG for the tests. |
Date: |
Wed, 10 Mar 2021 01:46:34 -0500 |
This is an automated email from the git hooks/post-receive script.
mothacehe pushed a commit to branch master
in repository guix-cuirass.
The following commit(s) were added to refs/heads/master by this push:
new 50b423c Use EphemeralPG for the tests.
50b423c is described below
commit 50b423c2cd9694ae6cc97cd78add5595f57bdb71
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Wed Mar 10 07:44:58 2021 +0100
Use EphemeralPG for the tests.
* README: Update dependencies.
* tests/common.scm (pg-tmp): New procedure.
(test-init-db!): Use it.
* tests/database.scm ("db-close"): Do not drop database content.
* tests/http.scm: Ditto.
* tests/metrics.scm: Ditto.
---
README | 1 +
tests/common.scm | 12 +++++++++++-
tests/database.scm | 1 -
tests/http.scm | 1 -
tests/metrics.scm | 1 -
5 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/README b/README
index 30e92e9..8ead223 100644
--- a/README
+++ b/README
@@ -16,6 +16,7 @@ Cuirass currently depends on the following packages:
- Guile-zlib
- Guile-Mastodon
- Guile-Simple-ZMQ
+ - Ephemeral PostgreSQL (for the tests)
- Mailutils
- Fibers
diff --git a/tests/common.scm b/tests/common.scm
index 6b52d31..75cac1d 100644
--- a/tests/common.scm
+++ b/tests/common.scm
@@ -20,16 +20,26 @@
#:use-module (cuirass database)
#:use-module (cuirass parameters)
#:use-module (cuirass utils)
+ #:use-module (ice-9 popen)
+ #:use-module (ice-9 rdelim)
#:export (%db
test-init-db!))
(define %db
(make-parameter #f))
+(define (pg-tmp)
+ "Start a temporary PostgreSQL instance using ephemeralpg."
+ ;; Destroy the database right after disconnection.
+ (let* ((pipe (open-input-pipe "pg_tmp -w 1"))
+ (uri (read-string pipe)))
+ (close-pipe pipe)
+ uri))
+
(define (test-init-db!)
"Initialize the test database."
(%create-database? #t)
- (%cuirass-database "test_tmp")
+ (%package-database (pg-tmp))
(%db (db-open))
(%db-channel (make-worker-thread-channel
(lambda ()
diff --git a/tests/database.scm b/tests/database.scm
index 877a46d..7b24f51 100644
--- a/tests/database.scm
+++ b/tests/database.scm
@@ -551,6 +551,5 @@ timestamp, checkouttime, evaltime) VALUES ('guix', 0, 0, 0,
0);")
(test-assert "db-close"
(begin
- (exec-query (%db) (format #f "DROP OWNED BY CURRENT_USER;"))
(db-close (%db))
#t)))
diff --git a/tests/http.scm b/tests/http.scm
index 177cdca..d68babd 100644
--- a/tests/http.scm
+++ b/tests/http.scm
@@ -277,6 +277,5 @@
(test-assert "db-close"
(begin
- (exec-query (%db) (format #f "DROP OWNED BY CURRENT_USER;"))
(db-close (%db))
#t)))
diff --git a/tests/metrics.scm b/tests/metrics.scm
index 8e5daba..7cdcc4a 100644
--- a/tests/metrics.scm
+++ b/tests/metrics.scm
@@ -134,6 +134,5 @@ nix_name, log, status, timestamp, starttime, stoptime)
VALUES
(test-assert "db-close"
(begin
- (exec-query (%db) (format #f "DROP OWNED BY CURRENT_USER;"))
(db-close (%db))
#t)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Use EphemeralPG for the tests.,
Mathieu Othacehe <=