From 4aea90b1876179aab8d603a42533a6bdf97ccd3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 15 Jan 2020 18:35:14 +0100 Subject: 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'. --- guix/import/cpan.scm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'guix') 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 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) -- cgit v1.2.3