tests: Ensure 'elpa' test does not access the network.

Previously it would try to access the real elpa.gnu.org.  This would
succeed when network is available because "taxy-magit-section" is an
existing package.

* guix/import/elpa.scm (elpa-repository)
(package-from-elpa-repository?): Recognize 'gnu/http.
* tests/elpa.scm ("package-latest-release"): Use 'http' instead of
'https'.  Change "taxy-magit-section" to "fake-taxy-magit-section".
This commit is contained in:
Ludovic Courtès 2023-06-09 12:30:45 +02:00
parent f69d14d31a
commit 53bf9fba0c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
2 changed files with 20 additions and 17 deletions

View file

@ -461,13 +461,15 @@ (define elpa-repository
(and uri (and uri
(cond (cond
((string=? (uri-host uri) "elpa.gnu.org") ((string=? (uri-host uri) "elpa.gnu.org")
'gnu) (if (eq? (uri-scheme uri) 'http)
'gnu/http ;for testing
'gnu))
((string=? (uri-host uri) "elpa.nongnu.org") ((string=? (uri-host uri) "elpa.nongnu.org")
'nongnu) 'nongnu)
(else #f)))))))) (else #f))))))))
(define (package-from-elpa-repository? package) (define (package-from-elpa-repository? package)
(member (elpa-repository package) '(gnu nongnu))) (member (elpa-repository package) '(gnu gnu/http nongnu)))
(define %elpa-updater (define %elpa-updater
;; The ELPA updater. We restrict it to packages hosted on elpa.gnu.org ;; The ELPA updater. We restrict it to packages hosted on elpa.gnu.org

View file

@ -43,7 +43,7 @@ (define elpa-mock-archive
[(11 88 6) [(11 88 6)
nil "Integrated environment for *TeX*" tar nil "Integrated environment for *TeX*" tar
((:url . "http://www.gnu.org/software/auctex/"))]) ((:url . "http://www.gnu.org/software/auctex/"))])
(taxy-magit-section . (fake-taxy-magit-section .
[(0 12 2) [(0 12 2)
((emacs ((emacs
(26 3)) (26 3))
@ -88,8 +88,8 @@ (define (eval-test-with-elpa pkg)
(eval-test-with-elpa "auctex")) (eval-test-with-elpa "auctex"))
(test-equal "package-latest-release" (test-equal "package-latest-release"
(list '("https://elpa.gnu.org/packages/taxy-magit-section-0.12.2.tar") (list '("http://elpa.gnu.org/packages/fake-taxy-magit-section-0.12.2.tar")
'("https://elpa.gnu.org/packages/taxy-magit-section-0.12.2.tar.sig") '("http://elpa.gnu.org/packages/fake-taxy-magit-section-0.12.2.tar.sig")
(list (upstream-input (list (upstream-input
(name "magit-section") (name "magit-section")
(downstream-name "emacs-magit-section") (downstream-name "emacs-magit-section")
@ -105,12 +105,13 @@ (define (eval-test-with-elpa pkg)
(with-http-server `((200 ,(object->string elpa-mock-archive))) (with-http-server `((200 ,(object->string elpa-mock-archive)))
(parameterize ((current-http-proxy (%local-url))) (parameterize ((current-http-proxy (%local-url)))
(define source (define source
;; Note: Use 'http' URLs to the proxy is used.
(package-latest-release (package-latest-release
(dummy-package "emacs-taxy-magit-section" (dummy-package "emacs-fake-taxy-magit-section"
(version "0.0.0") (version "0.0.0")
(source (dummy-origin (source (dummy-origin
(method url-fetch) (method url-fetch)
(uri "https://elpa.gnu.org/xyz")))) (uri "http://elpa.gnu.org/xyz"))))
(list %elpa-updater))) (list %elpa-updater)))
(list (upstream-source-urls source) (list (upstream-source-urls source)