summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-01-31 16:14:59 +0100
committerLudovic Courtès <ludo@gnu.org>2021-01-31 21:49:58 +0100
commit13a7d2a538b00aa0a8cf9b999f1a4ff3e5959af9 (patch)
tree0781cb715eb947cd41d4a490c6a37fce047dd6e6 /tests
parent9c4869fe9ca76caafe3ccfebfcb4a22d44cdf3f5 (diff)
database: Validate #:nar-size and #:time when registering store items.
* guix/store/database.scm (assert-integer): New procedure. (update-or-insert): Use it to validate NAR-SIZE and TIME. * tests/store-database.scm ("sqlite-register with incorrect size"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/store-database.scm19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/store-database.scm b/tests/store-database.scm
index 17eea38c63a..d8f3ce80700 100644
--- a/tests/store-database.scm
+++ b/tests/store-database.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017, 2018, 2020 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2017, 2018, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
3;;; 3;;;
4;;; This file is part of GNU Guix. 4;;; This file is part of GNU Guix.
5;;; 5;;;
@@ -123,4 +123,21 @@
123 (pk 'welcome-exception! args) 123 (pk 'welcome-exception! args)
124 #t))))) 124 #t)))))
125 125
126(test-equal "sqlite-register with incorrect size"
127 'out-of-range
128 (call-with-temporary-output-file
129 (lambda (db-file port)
130 (delete-file db-file)
131 (catch #t
132 (lambda ()
133 (with-database db-file db
134 (sqlite-register db #:path "/gnu/foo"
135 #:references '("/gnu/bar")
136 #:deriver "/gnu/foo.drv"
137 #:hash (string-append "sha256:" (make-string 64 #\e))
138 #:nar-size -1234))
139 #f)
140 (lambda (key . _)
141 key)))))
142
126(test-end "store-database") 143(test-end "store-database")