Merge branch 'ungrafting' into staging
[jackhill/guix/guix.git] / tests / elpa.scm
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 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (test-elpa)
22 #:use-module (guix import elpa)
23 #:use-module (guix tests http)
24 #:use-module (srfi srfi-1)
25 #:use-module (srfi srfi-64)
26 #:use-module (ice-9 match)
27 #:use-module (web client))
28
29 (define elpa-mock-archive
30 '(1
31 (ace-window .
32 [(0 9 0)
33 ((avy
34 (0 2 0)))
35 "Quickly switch windows." single
36 ((:url . "https://github.com/abo-abo/ace-window")
37 (:keywords "window" "location"))])
38 (auctex .
39 [(11 88 6)
40 nil "Integrated environment for *TeX*" tar
41 ((:url . "http://www.gnu.org/software/auctex/"))])))
42
43 ;; Avoid collisions with other tests.
44 (%http-server-port 10300)
45
46 (test-begin "elpa")
47
48 (define (eval-test-with-elpa pkg)
49 ;; Set up an HTTP server and use it as a pseudo-proxy so that
50 ;; 'elpa->guix-package' talks to it.
51 (with-http-server `((200 ,(object->string elpa-mock-archive))
52 (200 "This is the description.")
53 (200 "fake tarball contents"))
54 (parameterize ((current-http-proxy (%local-url)))
55 (match (elpa->guix-package pkg #:repo 'gnu/http)
56 (('package
57 ('name "emacs-auctex")
58 ('version "11.88.6")
59 ('source
60 ('origin
61 ('method 'url-fetch)
62 ('uri ('string-append
63 "http://elpa.gnu.org/packages/auctex-" 'version ".tar"))
64 ('sha256 ('base32 (? string? hash)))))
65 ('build-system 'emacs-build-system)
66 ('home-page "http://www.gnu.org/software/auctex/")
67 ('synopsis "Integrated environment for *TeX*")
68 ('description "This is the description.")
69 ('license 'license:gpl3+))
70 #t)
71 (x
72 (pk 'fail x #f))))))
73
74 (test-assert "elpa->guix-package test 1"
75 (eval-test-with-elpa "auctex"))
76
77 (test-end "elpa")
78
79 ;; Local Variables:
80 ;; eval: (put 'with-http-server 'scheme-indent-function 1)
81 ;; End: