1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (test-cpan)
20 #:use-module (guix import cpan)
21 #:use-module (guix base32)
22 #:use-module (guix hash)
23 #:use-module (guix tests)
24 #:use-module (srfi srfi-64)
25 #:use-module (ice-9 match))
33 \"Test::Script\" : \"1.05\",
37 \"name\" : \"Foo-Bar\",
40 \"name\" : \"Foo-Bar-0.1\",
41 \"distribution\" : \"Foo-Bar\",
45 \"abstract\" : \"Fizzle Fuzz\",
46 \"download_url\" : \"http://example.com/Foo-Bar-0.1.tar.gz\",
47 \"author\" : \"GUIX\",
56 (test-assert "cpan->guix-package"
57 ;; Replace network resources with sample data.
58 (mock ((guix build download) url-fetch
59 (lambda* (url file-name #:key (mirrors '()))
60 (with-output-to-file file-name
64 ("http://api.metacpan.org/release/Foo-Bar"
66 ("http://api.metacpan.org/module/Test::Script"
67 "{ \"distribution\" : \"Test-Script\" }")
68 ("http://example.com/Foo-Bar-0.1.tar.gz"
70 (_ (error "Unexpected URL: " url))))))))
71 (match (cpan->guix-package "Foo::Bar")
73 ('name "perl-foo-bar")
77 ('uri ('string-append "http://example.com/Foo-Bar-"
82 ('build-system 'perl-build-system)
85 (("perl-test-script" ('unquote 'perl-test-script)))))
86 ('home-page "http://search.cpan.org/dist/Foo-Bar")
87 ('synopsis "Fizzle Fuzz")
88 ('description 'fill-in-yourself!)
89 ('license (package-license perl)))
90 (string=? (bytevector->nix-base32-string
91 (call-with-input-string test-source port-sha256))
99 (exit (= (test-runner-fail-count (test-runner-current)) 0))