Commit | Line | Data |
---|---|---|
a96524cc DT |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2015 David Thompson <davet@gnu.org> | |
3 | ;;; | |
4 | ;;; This file is part of GNU Guix. | |
5 | ;;; | |
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. | |
10 | ;;; | |
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. | |
15 | ;;; | |
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/>. | |
18 | ||
19 | (define-module (test-gem) | |
20 | #:use-module (guix import gem) | |
21 | #:use-module (guix base32) | |
22 | #:use-module (guix hash) | |
23 | #:use-module (guix tests) | |
24 | #:use-module ((guix build utils) #:select (delete-file-recursively)) | |
25 | #:use-module (srfi srfi-64) | |
26 | #:use-module (ice-9 match)) | |
27 | ||
28 | (define test-json | |
29 | "{ | |
30 | \"name\": \"foo\", | |
31 | \"version\": \"1.0.0\", | |
32 | \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\", | |
33 | \"info\": \"A cool gem\", | |
34 | \"homepage_uri\": \"https://example.com\", | |
35 | \"dependencies\": { | |
36 | \"runtime\": [ | |
37 | { \"name\": \"bundler\" }, | |
38 | { \"name\": \"bar\" } | |
39 | ] | |
40 | }, | |
41 | \"licenses\": [\"MIT\", \"Apache 2.0\"] | |
42 | }") | |
43 | ||
44 | (test-begin "gem") | |
45 | ||
46 | (test-assert "gem->guix-package" | |
47 | ;; Replace network resources with sample data. | |
48 | (mock ((guix import utils) url-fetch | |
49 | (lambda (url file-name) | |
50 | (match url | |
51 | ("https://rubygems.org/api/v1/gems/foo.json" | |
52 | (with-output-to-file file-name | |
53 | (lambda () | |
54 | (display test-json)))) | |
55 | (_ (error "Unexpected URL: " url))))) | |
56 | (match (gem->guix-package "foo") | |
57 | (('package | |
58 | ('name "ruby-foo") | |
59 | ('version "1.0.0") | |
60 | ('source ('origin | |
61 | ('method 'url-fetch) | |
62 | ('uri ('rubygems-uri "foo" 'version)) | |
63 | ('sha256 | |
64 | ('base32 | |
65 | "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk")))) | |
66 | ('build-system 'ruby-build-system) | |
67 | ('propagated-inputs | |
68 | ('quasiquote | |
69 | (("bundler" ('unquote 'bundler)) | |
70 | ("ruby-bar" ('unquote 'ruby-bar))))) | |
71 | ('synopsis "A cool gem") | |
e88d5fa9 | 72 | ('description "This package provides a cool gem") |
a96524cc DT |
73 | ('home-page "https://example.com") |
74 | ('license ('list 'expat 'asl2.0))) | |
75 | #t) | |
76 | (x | |
77 | (pk 'fail x #f))))) | |
78 | ||
79 | (test-end "gem") | |
80 | ||
81 | \f | |
82 | (exit (= (test-runner-fail-count (test-runner-current)) 0)) |