mirror of
git://git.savannah.gnu.org/guix/data-service.git
synced 2023-12-14 03:23:03 +01:00
Add a function to check if the test database is being used
This helps avoid problems when running the tests, and the test database not being used.
This commit is contained in:
parent
f57b5c4a9a
commit
b337c5fcb2
|
@ -17,10 +17,13 @@
|
|||
|
||||
(define-module (guix-data-service database)
|
||||
#:use-module (system foreign)
|
||||
#:use-module (ice-9 match)
|
||||
#:use-module (squee)
|
||||
#:export (with-postgresql-connection
|
||||
with-postgresql-transaction
|
||||
|
||||
check-test-database!
|
||||
|
||||
with-advisory-session-lock
|
||||
obtain-advisory-transaction-lock
|
||||
|
||||
|
@ -63,6 +66,12 @@
|
|||
(lambda (key . args)
|
||||
(exec-query conn "ROLLBACK;"))))
|
||||
|
||||
(define (check-test-database! conn)
|
||||
(match (exec-query conn "SELECT current_database()")
|
||||
(((name))
|
||||
(unless (string=? name "guix_data_service_test")
|
||||
(error "tests being run against non test database")))))
|
||||
|
||||
(define (with-advisory-session-lock conn lock f)
|
||||
(let ((lock-number (number->string (symbol-hash lock))))
|
||||
(exec-query conn
|
||||
|
|
Loading…
Reference in a new issue