1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
6 ;;; This file is part of GNU Guix.
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.
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.
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/>.
21 (define-module (test-gem)
22 #:use-module (guix import gem)
23 #:use-module (guix base32)
24 #:use-module (gcrypt hash)
25 #:use-module (guix tests)
26 #:use-module ((guix build utils) #:select (delete-file-recursively))
27 #:use-module (srfi srfi-64)
28 #:use-module (ice-9 match))
33 \"version\": \"1.0.0\",
34 \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\",
35 \"info\": \"A cool gem\",
36 \"homepage_uri\": \"https://example.com\",
39 { \"name\": \"bundler\" },
43 \"licenses\": [\"MIT\", \"Apache 2.0\"]
49 \"version\": \"1.0.0\",
50 \"sha\": \"f3676eafca9987cb5fe263df1edf2538bf6dafc712b30e17be3543a9680547a8\",
51 \"info\": \"Another cool gem\",
52 \"homepage_uri\": \"https://example.com\",
55 { \"name\": \"bundler\" }
61 (define test-bundler-json
63 \"name\": \"bundler\",
64 \"version\": \"1.14.2\",
65 \"sha\": \"3bb53e03db0a8008161eb4c816ccd317120d3c415ba6fee6f90bbc7f7eec8690\",
66 \"info\": \"Ruby gem bundler\",
67 \"homepage_uri\": \"https://bundler.io/\",
71 \"licenses\": [\"MIT\"]
76 (test-assert "gem->guix-package"
77 ;; Replace network resources with sample data.
78 (mock ((guix http-client) http-fetch
81 ("https://rubygems.org/api/v1/gems/foo.json"
82 (values (open-input-string test-foo-json)
83 (string-length test-foo-json)))
84 (_ (error "Unexpected URL: " url)))))
85 (match (gem->guix-package "foo")
91 ('uri ('rubygems-uri "foo" 'version))
94 "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
95 ('build-system 'ruby-build-system)
98 (("bundler" ('unquote 'bundler))
99 ("ruby-bar" ('unquote 'ruby-bar)))))
100 ('synopsis "A cool gem")
101 ('description "This package provides a cool gem")
102 ('home-page "https://example.com")
103 ('license ('list 'license:expat 'license:asl2.0)))
108 (test-assert "gem-recursive-import"
109 ;; Replace network resources with sample data.
110 (mock ((guix http-client) http-fetch
113 ("https://rubygems.org/api/v1/gems/foo.json"
114 (values (open-input-string test-foo-json)
115 (string-length test-foo-json)))
116 ("https://rubygems.org/api/v1/gems/bar.json"
117 (values (open-input-string test-bar-json)
118 (string-length test-bar-json)))
119 ("https://rubygems.org/api/v1/gems/bundler.json"
120 (values (open-input-string test-bundler-json)
121 (string-length test-bundler-json)))
122 (_ (error "Unexpected URL: " url)))))
123 (match (gem-recursive-import "foo")
130 ('uri ('rubygems-uri "bar" 'version))
133 "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
134 ('build-system 'ruby-build-system)
137 (('"bundler" ('unquote 'bundler)))))
138 ('synopsis "Another cool gem")
139 ('description "Another cool gem")
140 ('home-page "https://example.com")
141 ('license #f)) ;no licensing info
143 ('name "ruby-bundler")
148 ('uri ('rubygems-uri "bundler" 'version))
151 "1446xiz7zg0bz7kgx9jv84y0s4hpsg61dj5l3qb0i00avc1kxd9v"))))
152 ('build-system 'ruby-build-system)
153 ('synopsis "Ruby gem bundler")
154 ('description "Ruby gem bundler")
155 ('home-page "https://bundler.io/")
156 ('license 'license:expat))
163 ('uri ('rubygems-uri "foo" 'version))
166 "1a270mlajhrmpqbhxcqjqypnvgrq4pgixpv3w9gwp1wrrapnwrzk"))))
167 ('build-system 'ruby-build-system)
170 (("bundler" ('unquote 'bundler))
171 ("ruby-bar" ('unquote 'ruby-bar)))))
172 ('synopsis "A cool gem")
173 ('description "This package provides a cool gem")
174 ('home-page "https://example.com")
175 ('license ('list 'license:expat 'license:asl2.0))))