1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
3 ;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
4 ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
5 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
7 ;;; This file is part of GNU Guix.
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22 (define-module (test-elpa)
23 #:use-module (guix import elpa)
24 #:use-module (guix tests)
25 #:use-module (guix tests http)
26 #:use-module (srfi srfi-1)
27 #:use-module (srfi srfi-64)
28 #:use-module (ice-9 match)
29 #:use-module (web client))
31 (define elpa-mock-archive
37 "Quickly switch windows." single
38 ((:url . "https://github.com/abo-abo/ace-window")
39 (:keywords "window" "location"))])
42 nil "Integrated environment for *TeX*" tar
43 ((:url . "http://www.gnu.org/software/auctex/"))])))
47 (define (eval-test-with-elpa pkg)
48 ;; Set up an HTTP server and use it as a pseudo-proxy so that
49 ;; 'elpa->guix-package' talks to it.
50 (with-http-server `((200 ,(object->string elpa-mock-archive))
51 (200 "This is the description.")
52 (200 "fake tarball contents"))
53 (parameterize ((current-http-proxy (%local-url)))
54 (match (elpa->guix-package pkg #:repo 'gnu/http)
56 ('name "emacs-auctex")
62 "http://elpa.gnu.org/packages/auctex-" 'version ".tar"))
63 ('sha256 ('base32 (? string? hash)))))
64 ('build-system 'emacs-build-system)
65 ('home-page "http://www.gnu.org/software/auctex/")
66 ('synopsis "Integrated environment for *TeX*")
67 ('description "This is the description.")
68 ('license 'license:gpl3+))
73 (test-assert "elpa->guix-package test 1"
74 (eval-test-with-elpa "auctex"))
76 (test-equal "guix-package->elpa-name: without 'upstream-name' property"
78 (guix-package->elpa-name (dummy-package "emacs-auctex")))
80 (test-equal "guix-package->elpa-name: with 'upstream-name' property"
82 (guix-package->elpa-name
83 (dummy-package "emacs-fake-name"
84 (properties '((upstream-name . "project"))))))
89 ;; eval: (put 'with-http-server 'scheme-indent-function 1)