From 5ff38984e8a0b26bf3b97477158f55b3721ee2da Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sun, 26 Jun 2016 18:40:31 +0200 Subject: Make %package-database a parameter object. Move it to (cuirass database). --- tests/database.scm | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/database.scm b/tests/database.scm index bdf0050..8c6efc0 100644 --- a/tests/database.scm +++ b/tests/database.scm @@ -26,26 +26,31 @@ #:derivation (string-append name ".drv") #:metadata '())) -(define tmp-database - (let ((dir (dirname (current-filename)))) - (string-append dir "/tmp.db"))) - -(define %db (make-parameter #t)) -(define %id (make-parameter #t)) - -(dynamic-wind - (const #t) - (λ () - (test-assert "db-init" - (%db (db-init tmp-database))) - - (test-assert "db-add-evaluation" - (%id (db-add-evaluation (%db) (make-dummy-job)))) - - (test-assert "db-get-evaluation" - (db-get-evaluation (%db) (%id))) - - (test-assert "db-close" - (db-close (%db)))) - (λ () - (delete-file tmp-database))) +(define %db + ;; Global Slot for a database object. + (make-parameter #t)) + +(define %id + ;; Global Slot for a job ID in the database. + (make-parameter #t)) + +(parameterize ((%package-database + ;; Use an empty and temporary database for the tests. + (let ((dir (dirname (current-filename)))) + (string-append dir "/tmp.db")))) + (dynamic-wind + (const #t) + (λ () + (test-assert "db-init" + (%db (db-init))) + + (test-assert "db-add-evaluation" + (%id (db-add-evaluation (%db) (make-dummy-job)))) + + (test-assert "db-get-evaluation" + (db-get-evaluation (%db) (%id))) + + (test-assert "db-close" + (db-close (%db)))) + (λ () + (delete-file (%package-database))))) -- cgit v1.2.3