summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-03-22 13:31:54 +0100
committerLudovic Courtès <ludo@gnu.org>2017-03-22 14:05:59 +0100
commitcdd7a7d2106d295ca10fc23a94b6e9d1c8b5a82a (patch)
treeb0abf265afd593ba8746358edc15b6609c5f72bb /tests
parent46f58390cb5a01d6cb59070e8e76e9a78e9b933e (diff)
downloadpatches-cdd7a7d2106d295ca10fc23a94b6e9d1c8b5a82a.tar
patches-cdd7a7d2106d295ca10fc23a94b6e9d1c8b5a82a.tar.gz
publish: Make the nar URL prefix a parameter.
* guix/scripts/publish.scm (narinfo-string): Add #:nar-path and honor it. (render-narinfo): Likewise. (make-request-handler): Likewise. (run-publish-server): Likewise. * tests/publish.scm ("custom nar path"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/publish.scm30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/publish.scm b/tests/publish.scm
index c0a0f72d9b..ea0f4a3477 100644
--- a/tests/publish.scm
+++ b/tests/publish.scm
@@ -232,6 +232,36 @@ References: ~%"
(list (assoc-ref info "Compression")
(dirname (assoc-ref info "URL")))))
+(test-equal "custom nar path"
+ ;; Serve nars at /foo/bar/chbouib instead of /nar.
+ (list `(("StorePath" . ,%item)
+ ("URL" . ,(string-append "foo/bar/chbouib/" (basename %item)))
+ ("Compression" . "none"))
+ 200
+ 404)
+ (let ((thread (with-separate-output-ports
+ (call-with-new-thread
+ (lambda ()
+ (guix-publish "--port=6798" "-C0"
+ "--nar-path=///foo/bar//chbouib/"))))))
+ (wait-until-ready 6798)
+ (let* ((base "http://localhost:6798/")
+ (part (store-path-hash-part %item))
+ (url (string-append base part ".narinfo"))
+ (nar-url (string-append base "foo/bar/chbouib/"
+ (basename %item)))
+ (body (http-get-port url)))
+ (list (filter (lambda (item)
+ (match item
+ (("Compression" . _) #t)
+ (("StorePath" . _) #t)
+ (("URL" . _) #t)
+ (_ #f)))
+ (recutils->alist body))
+ (response-code (http-get nar-url))
+ (response-code
+ (http-get (string-append base "nar/" (basename %item))))))))
+
(test-equal "/nar/ with properly encoded '+' sign"
"Congrats!"
(let ((item (add-text-to-store %store "fake-gtk+" "Congrats!")))