summaryrefslogtreecommitdiff
path: root/guix
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-01-15 18:35:14 +0100
committerLudovic Courtès <ludo@gnu.org>2020-01-15 18:40:43 +0100
commit4aea90b1876179aab8d603a42533a6bdf97ccd3c (patch)
tree6b117f50914a9a927788360f53217e04a6d534cd /guix
parent69f132554c6bd23df4610a21e636bde5f0578174 (diff)
downloadpatches-4aea90b1876179aab8d603a42533a6bdf97ccd3c.tar
patches-4aea90b1876179aab8d603a42533a6bdf97ccd3c.tar.gz
import: cpan: Rewrite tests to use an HTTP server instead of mocking.
* guix/import/cpan.scm (%metacpan-base-url): New variable. (module->dist-name, cpan-fetch): Refer to it instead of the hard-coded URL. * tests/cpan.scm ("cpan->guix-package"): Use 'with-http-server' instead of 'mock'.
Diffstat (limited to 'guix')
-rw-r--r--guix/import/cpan.scm12
1 files changed, 9 insertions, 3 deletions
diff --git a/guix/import/cpan.scm b/guix/import/cpan.scm
index 4320f94c98..7a97c7f8e8 100644
--- a/guix/import/cpan.scm
+++ b/guix/import/cpan.scm
@@ -61,7 +61,9 @@
cpan-fetch
cpan->guix-package
metacpan-url->mirror-url
- %cpan-updater))
+ %cpan-updater
+
+ %metacpan-base-url))
;;; Commentary:
;;;
@@ -70,6 +72,10 @@
;;;
;;; Code:
+(define %metacpan-base-url
+ ;; Base URL of the MetaCPAN API.
+ (make-parameter "https://fastapi.metacpan.org/v1/"))
+
;; Dependency of a "release".
(define-json-mapping <cpan-dependency> make-cpan-dependency cpan-dependency?
json->cpan-dependency
@@ -149,7 +155,7 @@
module is distributed with 'Test::Simple', so (module->dist-name \"ok\") would
return \"Test-Simple\""
(assoc-ref (json-fetch (string-append
- "https://fastapi.metacpan.org/v1/module/"
+ (%metacpan-base-url) "/module/"
module
"?fields=distribution"))
"distribution"))
@@ -176,7 +182,7 @@ or #f on failure. MODULE should be the distribution name, such as
\"Test-Script\" for the \"Test::Script\" module."
;; This API always returns the latest release of the module.
(json->cpan-release
- (json-fetch (string-append "https://fastapi.metacpan.org/v1/release/"
+ (json-fetch (string-append (%metacpan-base-url) "/release/"
name))))
(define (cpan-home name)