diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2021-05-11 15:01:00 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2021-05-16 23:28:11 +0200 |
| commit | 938ffcbb0589adc07dc12c79eda3e1e2bb9e7cf8 (patch) | |
| tree | 9e997f834176b4e438aa1a007d44532af59b1388 /tests | |
| parent | dc3504913de4a2c549482001f7087362f5400f29 (diff) | |
publish: Add '--negative-ttl'.
* guix/scripts/publish.scm (show-help, %options): Add '--negative-ttl'.
(render-narinfo, render-narinfo/cached, make-request-handler): Add #:negative-ttl
and honor it.
(run-publish-server): Add #:narinfo-negative-ttl and honor it.
(guix-publish): Honor '--negative-ttl'.
* tests/publish.scm ("negative TTL", "no negative TTL"): New tests.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/publish.scm | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/publish.scm b/tests/publish.scm index 3e67c435acf..c3d086995ab 100644 --- a/tests/publish.scm +++ b/tests/publish.scm | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2015 David Thompson <davet@gnu.org> | 2 | ;;; Copyright © 2015 David Thompson <davet@gnu.org> |
| 3 | ;;; Copyright © 2020 by Amar M. Singh <nly@disroot.org> | 3 | ;;; Copyright © 2020 by Amar M. Singh <nly@disroot.org> |
| 4 | ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> | 4 | ;;; Copyright © 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org> |
| 5 | ;;; | 5 | ;;; |
| 6 | ;;; This file is part of GNU Guix. | 6 | ;;; This file is part of GNU Guix. |
| 7 | ;;; | 7 | ;;; |
| @@ -700,6 +700,36 @@ References: ~%" | |||
| 700 | (= (response-content-length response) (stat:size (stat log))) | 700 | (= (response-content-length response) (stat:size (stat log))) |
| 701 | (first (response-content-type response)))))) | 701 | (first (response-content-type response)))))) |
| 702 | 702 | ||
| 703 | (test-equal "negative TTL" | ||
| 704 | `(404 42) | ||
| 705 | |||
| 706 | (call-with-temporary-directory | ||
| 707 | (lambda (cache) | ||
| 708 | (let ((thread (with-separate-output-ports | ||
| 709 | (call-with-new-thread | ||
| 710 | (lambda () | ||
| 711 | (guix-publish "--port=6786" "-C0" | ||
| 712 | "--negative-ttl=42s")))))) | ||
| 713 | (wait-until-ready 6786) | ||
| 714 | |||
| 715 | (let* ((base "http://localhost:6786/") | ||
| 716 | (url (string-append base (make-string 32 #\z) | ||
| 717 | ".narinfo")) | ||
| 718 | (response (http-get url))) | ||
| 719 | (list (response-code response) | ||
| 720 | (match (assq-ref (response-headers response) 'cache-control) | ||
| 721 | ((('max-age . ttl)) ttl) | ||
| 722 | (_ #f)))))))) | ||
| 723 | |||
| 724 | (test-equal "no negative TTL" | ||
| 725 | `(404 #f) | ||
| 726 | (let* ((uri (publish-uri | ||
| 727 | (string-append "/" (make-string 32 #\z) | ||
| 728 | ".narinfo"))) | ||
| 729 | (response (http-get uri))) | ||
| 730 | (list (response-code response) | ||
| 731 | (assq-ref (response-headers response) 'cache-control)))) | ||
| 732 | |||
| 703 | (test-equal "/log/NAME not found" | 733 | (test-equal "/log/NAME not found" |
| 704 | 404 | 734 | 404 |
| 705 | (let ((uri (publish-uri "/log/does-not-exist"))) | 735 | (let ((uri (publish-uri "/log/does-not-exist"))) |
