read-print: Recognize page breaks.
[jackhill/guix/guix.git] / tests / elpa.scm
CommitLineData
7f74a931
FB
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
9d6c6cb2 3;;; Copyright © 2020 Ludovic Courtès <ludo@gnu.org>
bea3b177 4;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
f21c70bc 5;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
7f74a931
FB
6;;;
7;;; This file is part of GNU Guix.
8;;;
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.
13;;;
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.
18;;;
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/>.
21
22(define-module (test-elpa)
23 #:use-module (guix import elpa)
f21c70bc 24 #:use-module (guix tests)
9d6c6cb2 25 #:use-module (guix tests http)
7f74a931
FB
26 #:use-module (srfi srfi-1)
27 #:use-module (srfi srfi-64)
9d6c6cb2
LC
28 #:use-module (ice-9 match)
29 #:use-module (web client))
7f74a931
FB
30
31(define elpa-mock-archive
32 '(1
33 (ace-window .
34 [(0 9 0)
35 ((avy
36 (0 2 0)))
37 "Quickly switch windows." single
38 ((:url . "https://github.com/abo-abo/ace-window")
39 (:keywords "window" "location"))])
40 (auctex .
41 [(11 88 6)
42 nil "Integrated environment for *TeX*" tar
43 ((:url . "http://www.gnu.org/software/auctex/"))])))
44
7f74a931
FB
45(test-begin "elpa")
46
47(define (eval-test-with-elpa pkg)
9d6c6cb2
LC
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)))
bea3b177 54 (match (elpa->guix-package pkg #:repo 'gnu/http)
9d6c6cb2
LC
55 (('package
56 ('name "emacs-auctex")
57 ('version "11.88.6")
58 ('source
59 ('origin
60 ('method 'url-fetch)
61 ('uri ('string-append
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+))
69 #t)
70 (x
71 (pk 'fail x #f))))))
7f74a931
FB
72
73(test-assert "elpa->guix-package test 1"
74 (eval-test-with-elpa "auctex"))
75
f21c70bc
XC
76(test-equal "guix-package->elpa-name: without 'upstream-name' property"
77 "auctex"
78 (guix-package->elpa-name (dummy-package "emacs-auctex")))
79
80(test-equal "guix-package->elpa-name: with 'upstream-name' property"
81 "project"
82 (guix-package->elpa-name
83 (dummy-package "emacs-fake-name"
84 (properties '((upstream-name . "project"))))))
85
7f74a931 86(test-end "elpa")
9d6c6cb2
LC
87
88;; Local Variables:
89;; eval: (put 'with-http-server 'scheme-indent-function 1)
90;; End: