summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2026-06-08 11:02:59 +0200
committerLudovic Courtès <ludo@gnu.org>2026-07-02 19:42:47 +0200
commit652e0c9110cae669767318dac7c09bcd4f56ce75 (patch)
tree581edf096126ae95aff4a3d97f20bcb080a3b095 /tests
parent26d7eb8a4adafc648ef035e91b6bbc4945d4c962 (diff)
store: Add ‘valid-path-syntax?’ and ‘valid-store-name?’.
* guix/store.scm (store-path?): Update docstring. (%store-item-charset): New variable. (valid-store-name?, valid-path-basename-syntax?, valid-path-syntax?): New procedures. * tests/store.scm ("valid-path-syntax?") ("valid-path-syntax? truncated hash") ("valid-path-syntax? slash") ("valid-path-syntax? leading dot") ("valid-path-syntax? prefix") ("valid-path-syntax? truncated"): New tests. Change-Id: Ic808dd5a8270fbea20e9c99c2861f30133d13b41 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/store.scm24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/store.scm b/tests/store.scm
index 87773bf0c36..e7ba7469047 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -78,6 +78,30 @@
78 (open-connection #f #:port port) 78 (open-connection #f #:port port)
79 'broken))) 79 'broken)))
80 80
81(test-assert "valid-path-syntax?"
82 (valid-path-syntax? (string-append (%store-prefix)
83 "/yp8mg1rwaw3y1p09bc8dx4l6rx4qx961-coreutils-9.1")))
84
85(test-assert "valid-path-syntax? truncated hash"
86 (not (valid-path-syntax?
87 (string-append (%store-prefix)
88 "/p8mg1rwaw3y1p09bc8dx4l6rx4qx961-coreutils-9.1"))))
89
90(test-assert "valid-path-syntax? slash"
91 (not (valid-path-syntax?
92 (string-append (%store-prefix)
93 "/yp8mg1rwaw3y1p09bc8dx4l6rx4qx961-coreutils-9.1/../../../etc/passwd"))))
94
95(test-assert "valid-path-syntax? leading dot"
96 (not (valid-path-syntax? (string-append (%store-prefix)
97 "/yp8mg1rwaw3y1p09bc8dx4l6rx4qx961-.leading-dot"))))
98
99(test-assert "valid-path-syntax? prefix"
100 (not (valid-path-syntax? (%store-prefix))))
101
102(test-assert "valid-path-syntax? truncated"
103 (not (valid-path-syntax? (string-append (%store-prefix) "/aaaaaaaaaaa"))))
104
81(test-equal "store-path-hash-part" 105(test-equal "store-path-hash-part"
82 "283gqy39v3g9dxjy26rynl0zls82fmcg" 106 "283gqy39v3g9dxjy26rynl0zls82fmcg"
83 (store-path-hash-part 107 (store-path-hash-part