projects/guix·blob javascript-team · refs

58 lines · 2.1 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2019, 2023 Ludovic Courtès <[email protected]>
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-deduplication)
20 #:use-module (guix tests)
21 #:use-module (guix store)
22 #:use-module (guix store roots)
23 #:use-module ((guix utils) #:select (call-with-temporary-directory))
24 #:use-module ((guix build utils) #:select (delete-file-recursively))
25 #:use-module ((guix config) #:select (%state-directory))
26 #:use-module (srfi srfi-1)
27 #:use-module (srfi srfi-64))
28
29(define %store #f)
30
31(test-begin "store-roots")
32
33;; The 'open-connection' call below gets guix-daemon to create
34;; %STATE-DIRECTORY/profiles.
35(set! %store (open-connection))
36
37(test-assert "gc-roots, regular root"
38 (let* ((item (add-text-to-store %store "something"
39 (random-text)))
40 (root (string-append %gc-roots-directory "/test-gc-root")))
41 (symlink item root)
42 (let ((result (member root (gc-roots))))
43 (delete-file root)
44 result)))
45
46(test-assert "gc-roots, indirect root"
47 (call-with-temporary-directory
48 (lambda (directory)
49 (let* ((item (add-text-to-store %store "something"
50 (random-text)))
51 (root (string-append directory "/gc-root")))
52 (symlink item root)
53 (add-indirect-root %store root)
54 (let ((result (member root (gc-roots))))
55 (delete-file root)
56 result)))))
57
58(test-end "store-roots")