aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-06-04 18:33:19 +0200
committerLudovic Courtès <ludo@gnu.org>2018-06-14 11:16:58 +0200
commitf8f9f7cabca3f0ea1f8b8cb4fecfc45889bdfb94 (patch)
tree9dbaccc4b647b39acd0dc0c3a03990f250583546 /tests
parent3931c76154d4f418d5ea9acc5e47bf911d371c24 (diff)
downloadguix-f8f9f7cabca3f0ea1f8b8cb4fecfc45889bdfb94.tar
guix-f8f9f7cabca3f0ea1f8b8cb4fecfc45889bdfb94.tar.gz
database: Fail registration when encountering unregistered references.
* guix/store/database.scm (add-reference-sql): Remove nested SELECT. (add-references): Expect REFERENCES to be a list of ids. (sqlite-register): Call 'path-id' for each of REFERENCES and pass it to 'add-references'. * tests/store-database.scm ("register-path with unregistered references"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/store-database.scm20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/store-database.scm b/tests/store-database.scm
index 7947368595..9562055fd1 100644
--- a/tests/store-database.scm
+++ b/tests/store-database.scm
@@ -74,4 +74,24 @@
(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 ()
+ (sqlite-register #:db-file db-file
+ #: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")