aboutsummaryrefslogtreecommitdiff
path: root/tests/store-database.scm
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2018-06-29 22:51:23 +0200
committerRicardo Wurmus <rekado@elephly.net>2018-06-29 22:51:23 +0200
commitf1728d43460e63b106dd446e70001d8e100eaf6d (patch)
tree9d211fabf9e200743be49e25d108d58ed88d2f60 /tests/store-database.scm
parentcda7f4bc8ecf331d623c7d37b01931a46830c648 (diff)
parent373cc3b74a6ad33fddf75c2d773a97b1775bda8e (diff)
downloadguix-f1728d43460e63b106dd446e70001d8e100eaf6d.tar.gz
guix-f1728d43460e63b106dd446e70001d8e100eaf6d.zip
Merge branch 'master' into core-updates
Diffstat (limited to 'tests/store-database.scm')
-rw-r--r--tests/store-database.scm45
1 files changed, 44 insertions, 1 deletions
diff --git a/tests/store-database.scm b/tests/store-database.scm
index 1348a75c26..fcae66e2de 100644
--- a/tests/store-database.scm
+++ b/tests/store-database.scm
@@ -18,8 +18,9 @@
(define-module (test-store-database)
#:use-module (guix tests)
- #:use-module ((guix store) #:hide (register-path))
+ #:use-module (guix store)
#:use-module (guix store database)
+ #:use-module ((guix utils) #:select (call-with-temporary-output-file))
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-64))
@@ -51,4 +52,46 @@
(null? (valid-derivers %store file))
(null? (referrers %store file))))))
+(test-equal "new database"
+ (list 1 2)
+ (call-with-temporary-output-file
+ (lambda (db-file port)
+ (delete-file db-file)
+ (with-database db-file db
+ (sqlite-register db
+ #:path "/gnu/foo"
+ #:references '()
+ #:deriver "/gnu/foo.drv"
+ #:hash (string-append "sha256:" (make-string 64 #\e))
+ #:nar-size 1234)
+ (sqlite-register db
+ #:path "/gnu/bar"
+ #:references '("/gnu/foo")
+ #:deriver "/gnu/bar.drv"
+ #:hash (string-append "sha256:" (make-string 64 #\a))
+ #:nar-size 4321)
+ (let ((path-id (@@ (guix store database) path-id)))
+ (list (path-id db "/gnu/foo")
+ (path-id db "/gnu/bar")))))))
+
+(test-assert "register-path with unregistered references"
+ ;; Make sure we get a "NOT NULL constraint failed: Refs.reference" error
+ ;; when we try to add references that are not registered yet. Better safe
+ ;; than sorry.
+ (call-with-temporary-output-file
+ (lambda (db-file port)
+ (delete-file db-file)
+ (catch 'sqlite-error
+ (lambda ()
+ (with-database db-file db
+ (sqlite-register db #:path "/gnu/foo"
+ #:references '("/gnu/bar")
+ #:deriver "/gnu/foo.drv"
+ #:hash (string-append "sha256:" (make-string 64 #\e))
+ #:nar-size 1234))
+ #f)
+ (lambda args
+ (pk 'welcome-exception! args)
+ #t)))))
+
(test-end "store-database")