diff options
| author | Caleb Ristvedt <caleb.ristvedt@cune.org> | 2018-05-27 19:19:30 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2018-06-01 15:35:32 +0200 |
| commit | 7f9d184d9b688d13ce76eefabaddcfa76bdde2b5 (patch) | |
| tree | 49e5cfef7619c8faff4424990831ddea30e8d9dc /tests/store-database.scm | |
| parent | d59e75f3b5b82692bd250a1a3a9965397bb588c5 (diff) | |
Add (gnu store database).
* guix/config.scm.in (%store-database-directory): New variable.
* guix/store/database.scm: New file.
* tests/store-database.scm: New file.
* Makefile.am (STORE_MODULES): New variable.
(MODULES, MODULES_NOT_COMPILED): Adjust accordingly.
(SCM_TESTS) [HAVE_GUILE_SQLITE3]: Add tests/store-database.scm.
Co-authored-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests/store-database.scm')
| -rw-r--r-- | tests/store-database.scm | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/store-database.scm b/tests/store-database.scm new file mode 100644 index 00000000000..1348a75c261 --- /dev/null +++ b/tests/store-database.scm | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (test-store-database) | ||
| 20 | #:use-module (guix tests) | ||
| 21 | #:use-module ((guix store) #:hide (register-path)) | ||
| 22 | #:use-module (guix store database) | ||
| 23 | #:use-module (srfi srfi-26) | ||
| 24 | #:use-module (srfi srfi-64)) | ||
| 25 | |||
| 26 | ;; Test the (guix store database) module. | ||
| 27 | |||
| 28 | (define %store | ||
| 29 | (open-connection-for-tests)) | ||
| 30 | |||
| 31 | |||
| 32 | (test-begin "store-database") | ||
| 33 | |||
| 34 | (test-assert "register-path" | ||
| 35 | (let ((file (string-append (%store-prefix) "/" (make-string 32 #\f) | ||
| 36 | "-fake"))) | ||
| 37 | (when (valid-path? %store file) | ||
| 38 | (delete-paths %store (list file))) | ||
| 39 | (false-if-exception (delete-file file)) | ||
| 40 | |||
| 41 | (let ((ref (add-text-to-store %store "ref-of-fake" (random-text))) | ||
| 42 | (drv (string-append file ".drv"))) | ||
| 43 | (call-with-output-file file | ||
| 44 | (cut display "This is a fake store item.\n" <>)) | ||
| 45 | (register-path file | ||
| 46 | #:references (list ref) | ||
| 47 | #:deriver drv) | ||
| 48 | |||
| 49 | (and (valid-path? %store file) | ||
| 50 | (equal? (references %store file) (list ref)) | ||
| 51 | (null? (valid-derivers %store file)) | ||
| 52 | (null? (referrers %store file)))))) | ||
| 53 | |||
| 54 | (test-end "store-database") | ||
