store-roots.scm 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2019 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. (define-module (test-store-deduplication)
  19. #:use-module (guix tests)
  20. #:use-module (guix store)
  21. #:use-module (guix store roots)
  22. #:use-module ((guix utils) #:select (call-with-temporary-directory))
  23. #:use-module (srfi srfi-1)
  24. #:use-module (srfi srfi-64))
  25. (define %store
  26. (open-connection))
  27. (test-begin "store-roots")
  28. (test-assert "gc-roots, regular root"
  29. (let* ((item (add-text-to-store %store "something"
  30. (random-text)))
  31. (root (string-append %gc-roots-directory "/test-gc-root")))
  32. (symlink item root)
  33. (let ((result (member root (gc-roots))))
  34. (delete-file root)
  35. result)))
  36. (test-assert "gc-roots, indirect root"
  37. (call-with-temporary-directory
  38. (lambda (directory)
  39. (let* ((item (add-text-to-store %store "something"
  40. (random-text)))
  41. (root (string-append directory "/gc-root")))
  42. (symlink item root)
  43. (add-indirect-root %store root)
  44. (let ((result (member root (gc-roots))))
  45. (delete-file root)
  46. result)))))
  47. (test-end "store-roots")